Resize of Custom Control And Excluding control
-
Witch attribute I need to set, so that designer can resize control only vertical or horizontal Simular to Textbox. It can be resized only by width as long as it doesn't have Multiline property to true. Is there an if statement, so that code executing code is excluded, while the control is being rendered by Design view. Currently I am at work, so I don't have much time to google around. I have Read a Book "GDI+ Application Custom Controls with Visual C# 2005", This book is nearly an introduction to custom controls. Is there any book with more advance topics?
-
Witch attribute I need to set, so that designer can resize control only vertical or horizontal Simular to Textbox. It can be resized only by width as long as it doesn't have Multiline property to true. Is there an if statement, so that code executing code is excluded, while the control is being rendered by Design view. Currently I am at work, so I don't have much time to google around. I have Read a Book "GDI+ Application Custom Controls with Visual C# 2005", This book is nearly an introduction to custom controls. Is there any book with more advance topics?
Saksida Bojan wrote:
Witch attribute I need to set, so that designer can resize control only vertical or horizontal Simular to Textbox. It can be resized only by width as long as it doesn't have Multiline property to true.
That's probably not done using an attribute, but by setting some maximum and minimum widths. Perhaps even guarding those, in the Resize-event.
Saksida Bojan wrote:
Currently I am at work, so I don't have much time to google around.
:)
I are Troll :suss:
-
Saksida Bojan wrote:
Witch attribute I need to set, so that designer can resize control only vertical or horizontal Simular to Textbox. It can be resized only by width as long as it doesn't have Multiline property to true.
That's probably not done using an attribute, but by setting some maximum and minimum widths. Perhaps even guarding those, in the Resize-event.
Saksida Bojan wrote:
Currently I am at work, so I don't have much time to google around.
:)
I are Troll :suss:
Eddy Vluggen wrote:
That's probably not done using an attribute, but by setting some maximum and minimum widths. Perhaps even guarding those, in the Resize-event.
Does not help. Even if I set Minimum and maximum width, designer still shows that can be resized in any direction. Look at Textbox and notice you can't change height, because simply you can't grab on resize rectangle when control is selceted
-
Eddy Vluggen wrote:
That's probably not done using an attribute, but by setting some maximum and minimum widths. Perhaps even guarding those, in the Resize-event.
Does not help. Even if I set Minimum and maximum width, designer still shows that can be resized in any direction. Look at Textbox and notice you can't change height, because simply you can't grab on resize rectangle when control is selceted
Saksida Bojan wrote:
Does not help. Even if I set Minimum and maximum width, designer still shows that can be resized in any direction. Look at Textbox and notice you can't change height, because simply you can't grab on resize rectangle when control is selceted
I found this solution on SO[^], which you probably already tried;
protected override void SetBoundsCore(int x, int y,
int width, int height, BoundsSpecified specified)
{
if (this.DesignMode)
base.SetBoundsCore(x, y, 500, 490, specified);
else
base.SetBoundsCore(x, y, width, height, specified);
}I are Troll :suss:
-
Saksida Bojan wrote:
Does not help. Even if I set Minimum and maximum width, designer still shows that can be resized in any direction. Look at Textbox and notice you can't change height, because simply you can't grab on resize rectangle when control is selceted
I found this solution on SO[^], which you probably already tried;
protected override void SetBoundsCore(int x, int y,
int width, int height, BoundsSpecified specified)
{
if (this.DesignMode)
base.SetBoundsCore(x, y, 500, 490, specified);
else
base.SetBoundsCore(x, y, width, height, specified);
}I are Troll :suss:
I am sorry for late reply, but this code does exactly as i would use resize event or setting min and max size.
this.DesignMode
is part of an answer and i thank you for it. I have just found a book with more advance topics. I am sure it will be there. Thank you for your time -
Saksida Bojan wrote:
Does not help. Even if I set Minimum and maximum width, designer still shows that can be resized in any direction. Look at Textbox and notice you can't change height, because simply you can't grab on resize rectangle when control is selceted
I found this solution on SO[^], which you probably already tried;
protected override void SetBoundsCore(int x, int y,
int width, int height, BoundsSpecified specified)
{
if (this.DesignMode)
base.SetBoundsCore(x, y, 500, 490, specified);
else
base.SetBoundsCore(x, y, width, height, specified);
}I are Troll :suss:
I Found the way to use what i wanted. I added a dll reference: system.Design.dll I added using System.Windows.Form.Design
[ToolboxItem(true)]
[Designer(typeof(testDesigner))] // Designer need
public class test : Button
{
[Browsable(true)]
public bool MultiLine
{
get
{
return testDesigner.m;
}
set
{
testDesigner.m = value;
}
}
}
public class testDesigner : ControlDesigner
{
public static bool m;
public override SelectionRules SelectionRules
{
get
{
if (!m)
return SelectionRules.LeftSizeable | SelectionRules.RightSizeable | SelectionRules.Visible | SelectionRules.Moveable;
else
return SelectionRules.BottomSizeable | SelectionRules.TopSizeable | SelectionRules.Visible | SelectionRules.Moveable;
}
}
} -
I Found the way to use what i wanted. I added a dll reference: system.Design.dll I added using System.Windows.Form.Design
[ToolboxItem(true)]
[Designer(typeof(testDesigner))] // Designer need
public class test : Button
{
[Browsable(true)]
public bool MultiLine
{
get
{
return testDesigner.m;
}
set
{
testDesigner.m = value;
}
}
}
public class testDesigner : ControlDesigner
{
public static bool m;
public override SelectionRules SelectionRules
{
get
{
if (!m)
return SelectionRules.LeftSizeable | SelectionRules.RightSizeable | SelectionRules.Visible | SelectionRules.Moveable;
else
return SelectionRules.BottomSizeable | SelectionRules.TopSizeable | SelectionRules.Visible | SelectionRules.Moveable;
}
}
}