# [.net] [SOLVED] Control Painting Peculiarities

This topic is 3603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

A small problem, probably easily solved by those much more proficient in C#, .NET, GUI programming, or all the above. My class A:Control attempts to add class B:Control to it. For all intents and purposes, all class A does is draw a 'border' on the inside of the control which it does nicely. Class B attempts to draw a constant string at location 0,0. Now then, when class A iniates class B and sets the Dock property to Dockstyle.Fill prior to 'this.Controls.Add(varB);', B does in fact draw its pretty little string, but unfortunately the border is not drawn in A since it is, of course, covered by B. However, when I try to do away with setting the Dock property and instead set the Location property to new Point(0,0); and Size to new Size(this.width-1,this.height-1);, the border in A is drawn, but B does nothing. Nada. Zilch. Merely having B draw the border won't suffice since at some point multiple B's will be displayed in A(i.e., one on the top half, one on the bottom half, maybe one to the right) and they all need to have that pretty little border, amongst other things. Any help is appreciated in advance. [UPDATE!] Apparently, when Size and Location are set, and the control is moved in the form design editor of VS, it throws an exception about invalid parameters for the line:
Bitmap buffer=new Bitmap(this.Width-vscroll.Width,this.Height-hscroll.Height);
However, when the Dock is set, it is good to go. It seems that either this.Width or this.Height isn't set properly, or similiar, even though I've set Size already, which confuzzles me. I guess I'd better research just exactly what all goes on behind the scenes when the Dock property is set... :/ [SOLVED!] For some weird reason, SetBounds does the trick, even though I would think setting Size and Location would be the same... o_O If anyone can explain that to me, I'd be much appreciative... [Edited by - nerd_boy on August 11, 2008 5:06:04 PM]

##### Share on other sites
Quote:
 Original post by nerd_boyHowever, when I try to do away with setting the Dock property and instead set the Location property to new Point(0,0); and Size to new Size(this.width-1,this.height-1);, the border in A is drawn, but B does nothing. Nada. Zilch.
Instead of doing this, set the Padding property on the outer control (A) to 1 and leave the Dock on B as Fill.

##### Share on other sites
That should help for now, I suppose, until I get to where I do need multiple. :/

Thanks benryves.
Again. :p

1. 1
2. 2
3. 3
4. 4
Rutin
16
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631418
• Total Posts
2999975
×