Matt's blog

24 Sep, 2009

Some general Winforms coding info

Posted by: DJMatty In: Geek Post

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;

No Responses to "Some general Winforms coding info"

Comment Form

You must be logged in to post a comment.

Categories

My Flickr Photos


By Erik Rasmussen

Visitors

hits counter

Flickr PhotoStream

    H&K Cake CuttingDave Dev & H&Ks WeddingFiley 07

About

I've embarked on a big journey, sold up and moved from the UK to Australia! Now I'm loving the life over here!