dvplayltd
asked on
How to draw lines or rectangle in my WInForm ?
Hi experts!
Im using C# 2008 , WinForm NET 2. Probably is stupid question, but I needed to know how to draw line or rectangle or circle in my WinForm. This object need to be static and if is possible to be visible in design view of form.
Probably best is to draw them as control, but I can not find such controls in Toolbox ?
Do I need third part components for this ?
I cannot use Group Bar because I have controls in loop of the forms.
Im using C# 2008 , WinForm NET 2. Probably is stupid question, but I needed to know how to draw line or rectangle or circle in my WinForm. This object need to be static and if is possible to be visible in design view of form.
Probably best is to draw them as control, but I can not find such controls in Toolbox ?
Do I need third part components for this ?
I cannot use Group Bar because I have controls in loop of the forms.
ASKER
To kaufmed
Thank you, but not help for my purpose, it will be too slow.
I have other object and want when move this object to move and line. With this - yes it will work but will take many time to set exatly position.
Thank you, but not help for my purpose, it will be too slow.
I have other object and want when move this object to move and line. With this - yes it will work but will take many time to set exatly position.
I'm not sure I understand what you mean by "it will be too slow." What will cause the following to take "too much" time, as you understand it?
public partial class Form1 : Form
{
Graphics g;
public Form1()
{
InitializeComponent();
g = this.CreateGraphics();
}
private void button1_Click(object sender, EventArgs e)
{
g.Clear(this.BackColor);
this.button1.Top = this.button1.Top - 10;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int bottomPos = this.button1.Top + this.button1.Height;
g.DrawLine(Pens.Black, new Point(this.button1.Left, bottomPos + 5), new Point(this.button1.Left + this.button1.Width, bottomPos + 5));
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very good , thank you !
untitled.JPG