Hi all,
Is it possible to determine whether a control is selected at design-time, if so, how?
Cheers.
Printable View
Hi all,
Is it possible to determine whether a control is selected at design-time, if so, how?
Cheers.
how do you mean? Can you explain further?
I think I understand what you mean but for what purpose exactly?
I have a user created control that has no border, but does have a backcolor.
If its parent container control's backcolor is the same then it is effectively invisible.
To get around this if the control is being rendered as design-time and the backcolors are the same then it draws a dotted border.
When the control is selected at design time the designer draws its own dotted border, so my manually drawn one isn't needed.
P.S. The reason having an effectively invisible control on a form is that at run-time the form doesn't exist and is used purely to lay out a GUI for custom rendering using Microsoft XNA.
I'm not sure whether this will be useful or not but your control inherits the protected DesignMode property from the Component class. In theory you could just wrap the code that draws your border in an 'if' block:That said, I've got a feeling that DesignMode will only be 'true' if the control itself is being designed, as opposed to residing on a form that's being designed. Give it a try and see what happens.CSharp Code:
if (!this.DesignMode) { // Draw border. }
Thanks for the reply jmcilhinney, but that's not quite what i'm after.
I know i can draw the control differently depending on whether we're in design mode or not.
What i want to do is draw it different if we are in design mode AND this control is the control that's selected in the designer. It's the second bit i'm having trouble with.
If it can't be done then it can't be done, i just thought it might be a nice touch.