Click here to Skip to main content
15,913,773 members
Home / Discussions / C#
   

C#

 
GeneralRe: Why this ? Pin
Colin Angus Mackay10-Sep-04 7:46
Colin Angus Mackay10-Sep-04 7:46 
GeneralRe: Why this ? Pin
Anonymous10-Sep-04 20:47
Anonymous10-Sep-04 20:47 
GeneralRe: Why this ? Pin
Colin Angus Mackay10-Sep-04 22:57
Colin Angus Mackay10-Sep-04 22:57 
QuestionWeb-style UI with re-flow - seen any examples? Pin
Mal Ross9-Sep-04 22:27
Mal Ross9-Sep-04 22:27 
AnswerRe: Web-style UI with re-flow - seen any examples? Pin
sreejith ss nair9-Sep-04 23:41
sreejith ss nair9-Sep-04 23:41 
GeneralRe: Web-style UI with re-flow - seen any examples? Pin
Mal Ross9-Sep-04 23:47
Mal Ross9-Sep-04 23:47 
AnswerRe: Web-style UI with re-flow - seen any examples? Pin
mav.northwind10-Sep-04 1:45
mav.northwind10-Sep-04 1:45 
AnswerRe: Web-style UI with re-flow - seen any examples? Pin
mav.northwind10-Sep-04 2:45
mav.northwind10-Sep-04 2:45 
ReHi!
Because such a flow panel could be useful for me too, I wrote a quick initial version.
You can try it out if you like:
public class FlowLayoutPanel : Panel
{
	public FlowLayoutPanel()
	{}
 
	private Orientation _orient = Orientation.Horizontal;
	[DefaultValue(Orientation.Horizontal)]
	public Orientation Orientation
	{
		get { return _orient; }
		set
		{
			_orient = value;
			RecalcLayout();
			Invalidate();
		}
	}
 
	private void RecalcLayout()
	{
		if (this.Controls.Count==0)
		{
			this.Size = new System.Drawing.Size(100,100);
			return;
		}

		int x=0,y=0,h=0,w=0;
		if (Orientation == Orientation.Horizontal)
		{
			// Width stays constant, height differs
			foreach (Control c in Controls)
			{
				if (x+c.Width > this.Width)
				{
					x = 0;
					y = h+1;
				}
				c.Left = x;
				c.Top = y;
				
				h = Math.Max(h,c.Bottom);
				x += c.Width;
			}
			this.Height = h;
		} 
		else
		{
			// Height stays constant, width differs
			foreach (Control c in Controls)
			{
				if (y+c.Height > this.Height)
				{
					y = 0;
					x = w+1;
				}
				c.Left = x;
				c.Top = y;
				
				w = Math.Max(w,c.Right);
				y += c.Height;
			}
			this.Width = w;
		}
	}
	
	protected override void OnResize(EventArgs eventargs)
	{
		RecalcLayout();
		base.OnResize (eventargs);
	}
	
	protected override void OnControlAdded(ControlEventArgs e)
	{
		RecalcLayout();
		base.OnControlAdded (e);
	}
	
	protected override void OnControlRemoved(ControlEventArgs e)
	{
		RecalcLayout();
		base.OnControlRemoved (e);
	}
}

Regards,
mav
GeneralRe: Web-style UI with re-flow - seen any examples? Pin
Mal Ross10-Sep-04 4:46
Mal Ross10-Sep-04 4:46 
Generalcall Javascript Function Pin
Ikarus769-Sep-04 22:16
Ikarus769-Sep-04 22:16 
Generaldisable cross button Pin
xiaowenjie9-Sep-04 20:22
xiaowenjie9-Sep-04 20:22 
GeneralRe: disable cross button Pin
Jay Shankar9-Sep-04 20:56
Jay Shankar9-Sep-04 20:56 
GeneralRe: disable cross button Pin
Stefan Troschuetz10-Sep-04 2:39
Stefan Troschuetz10-Sep-04 2:39 
Questionhow to import COM DLL in ASP.NET using C# Pin
zahid_ash9-Sep-04 19:09
zahid_ash9-Sep-04 19:09 
AnswerRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair9-Sep-04 20:00
sreejith ss nair9-Sep-04 20:00 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash9-Sep-04 20:37
zahid_ash9-Sep-04 20:37 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair9-Sep-04 21:10
sreejith ss nair9-Sep-04 21:10 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash9-Sep-04 21:37
zahid_ash9-Sep-04 21:37 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair9-Sep-04 22:36
sreejith ss nair9-Sep-04 22:36 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash9-Sep-04 23:15
zahid_ash9-Sep-04 23:15 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair9-Sep-04 23:29
sreejith ss nair9-Sep-04 23:29 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash10-Sep-04 0:03
zahid_ash10-Sep-04 0:03 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair10-Sep-04 0:12
sreejith ss nair10-Sep-04 0:12 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
zahid_ash10-Sep-04 0:23
zahid_ash10-Sep-04 0:23 
GeneralRe: how to import COM DLL in ASP.NET using C# Pin
sreejith ss nair10-Sep-04 0:34
sreejith ss nair10-Sep-04 0:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.