Just some minor points to notes on C#.
1. The effective width or height of a control becomes zero when the control is docked.
That is, the Control.Height and Control.Width properties may return zero even it does occupy screen pixels. From my observation, there are some factors to this:
- How the control itself is docked (Left, Right, Top, Bottom, or Fill)
- How other control is docked
- The situation only exists when the control has already been added to a control collection (Control.Controls)
You should be extremely careful if you have some how working with the control size if you have it docked. Take my situation as example, my form dynamically loads controls and resizes accordingly. The Control.SuspendLayout() and Control.ResumeLayout() methods are extremely useful in this case to avoid immediate changes of the size property:
this.SuspendLayout();
this.Controls.Add(my_control);
my_control.Dock = DockStyle.Fill;
this.Height += my_control.Height;
this.ResumeLayout();2. Special keys like Arrows, ESC and TAB do not fire KeyPress, KeyUp or KeyDown events
As title, Control.KeyPress, Control.KeyUp and Control.KeyDown do not help. To catch these key you need to override the Control.ProcessDialogKey() method.
Example:
protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData == Keys.Escape)
{
this.Close();
return true;
}
return base.ProcessDialogKey (keyData);
}
BTW. All the above based on .NET Framework 1.1 that I am using. Newer versions may have different behavior.


1 comment(s):
HTML Tags allowed (e.g. <b>, <i>, <a>)