Some general Winforms coding info

The difference between Control.Invalidate, Control.Update and Control.Refresh:

Control.Invalidate()

Adds a region or a control to the update region of a window

Control.Update()

Sends WM_PAINT to the window if the windows update region is not empty (sends directly to wndproc bypassing the apps message queue)

Control.Refresh()

Calls invalidate and then update

String format alignment enums

The names of LineAlignment and Alignment (plus the descriptions in their tooltips) are confusing and I keep forgetting which one is which.

StringFormat.LineAlignment

Text alignment vertically

StringFormat.Alignment

Text alignment horizontally

Scrollbars

The scroll value automatically takes into account not scrolling the amount at the end of the range given by LargeChange. According to reflector:

case ScrollEventType.SmallDecrement:

newValue = Math.Max(this.value - this.SmallChange, this.minimum);

break;

case ScrollEventType.SmallIncrement:

newValue = Math.Min((int) (this.value + this.SmallChange),

(int) ((this.maximum - this.LargeChange) + 1));

break;

case ScrollEventType.LargeDecrement:

newValue = Math.Max(this.value - this.LargeChange,

this.minimum);

break;

case ScrollEventType.LargeIncrement:

newValue = Math.Min((int) (this.value + this.LargeChange),

(int) ((this.maximum - this.LargeChange) + 1));

break;

Comments are closed