Sign in to follow this  
nerd_boy

[.net] [SOLVED] Control Painting Peculiarities

Recommended Posts

nerd_boy    720
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 this post


Link to post
Share on other sites
benryves    1999
I'm afraid I don't think I can help you directly, but:
Quote:
Original post by nerd_boy
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.
Instead of doing this, set the Padding property on the outer control (A) to 1 and leave the Dock on B as Fill.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this