Tuesday 15 May 2012

c# - How do I implement scrolling for a Custom Control? -



c# - How do I implement scrolling for a Custom Control? -

how implement scrolling custom control? command custom drawn , height variable, , part of command contains menu if there many items in control, i'll need able set scroll bars there. i've not been able find clues on how this. did see scrollablecontrol, i'm still not sure if that's need.

also, how command know when needs show scroll bars? because command custom drawn there's no real "controls" in there it's bunch of pixels drawn onto it's not can set autoscroll true , can't anyway because it's not main part of command needs scrolling, it's particular location on command need have scrollbars.

if custom command inherits panel control, set size of content in custom command setting:

this.autoscrollminsize = new size(yourwidth, yourheight);

if control's clientsize.height greater yourheight, won't scrollbars. if it's less, scrollbar.

in paint method, add together beginning:

protected override void onpaint(painteventargs e) { e.graphics.translatetransform(this.autoscrollposition.x, this.autoscrollposition.y);

now paint gets automatically transformed scrolling coordinates.

c# .net winforms gdi+ gdi

No comments:

Post a Comment