E
Erdem
Hi everyone
I am developing a custom control (inherit from control) that just
draws
rectangle border.
Then i insert more than 50 instance of this control in a panel.
The thing i am trying to do is : to draw Selection Rectangle in panel.
User
would be able to select instances of my custom controls in panel ,
which are
in selection rectangle.
The problem is;
While i am drawing selection rectangle, my custom controls (that are
in
panel) blinks (they repaint themselves). There are also labels in
panel but
they dont get repaint. this shows i am making a mistake with my
custom
control paint event.
When i set -- >SetStyle(ControlStyles.Opaque, true); , blinking
decreases
but this time control doesnt draw its background (because of style it
is
meant to be
) so it is not usefull.
Any Suggestions for decreasing blinking of my custom control (not to
make it, repaint itself )
Thanks in advance
Erdem
this is my custom control's constructor and Paint event
public myPanel()
{
InitializeComponent();
SetStyle(ControlStyles.ContainerControl, false);
SetStyle(ControlStyles.DoubleBuffer,true);
SetStyle(ControlStyles.AllPaintingInWmPaint,false);
SetStyle(ControlStyles.ResizeRedraw,true);
SetStyle(ControlStyles.UserPaint,true);
SetStyle(ControlStyles.SupportsTransparentBackColor,true);
}
protected override void OnPaint(PaintEventArgs e)
{
Color borderColor = _borderDrawColor;
if (Selected)
borderColor = BorderSelectedColor;
Graphics g = e.Graphics;
ControlPaint.DrawBorder(
g,
new Rectangle(0, 0, this.Width, this.Height),
borderColor,
_borderWidth,
ButtonBorderStyle.Solid,
borderColor,
_borderWidth,
ButtonBorderStyle.Solid,
borderColor,
_borderWidth,
ButtonBorderStyle.Solid,
borderColor,
_borderWidth,
ButtonBorderStyle.Solid);
g.Dispose();
}
I am developing a custom control (inherit from control) that just
draws
rectangle border.
Then i insert more than 50 instance of this control in a panel.
The thing i am trying to do is : to draw Selection Rectangle in panel.
User
would be able to select instances of my custom controls in panel ,
which are
in selection rectangle.
The problem is;
While i am drawing selection rectangle, my custom controls (that are
in
panel) blinks (they repaint themselves). There are also labels in
panel but
they dont get repaint. this shows i am making a mistake with my
custom
control paint event.
When i set -- >SetStyle(ControlStyles.Opaque, true); , blinking
decreases
but this time control doesnt draw its background (because of style it
is
meant to be

Any Suggestions for decreasing blinking of my custom control (not to
make it, repaint itself )
Thanks in advance
Erdem
this is my custom control's constructor and Paint event
public myPanel()
{
InitializeComponent();
SetStyle(ControlStyles.ContainerControl, false);
SetStyle(ControlStyles.DoubleBuffer,true);
SetStyle(ControlStyles.AllPaintingInWmPaint,false);
SetStyle(ControlStyles.ResizeRedraw,true);
SetStyle(ControlStyles.UserPaint,true);
SetStyle(ControlStyles.SupportsTransparentBackColor,true);
}
protected override void OnPaint(PaintEventArgs e)
{
Color borderColor = _borderDrawColor;
if (Selected)
borderColor = BorderSelectedColor;
Graphics g = e.Graphics;
ControlPaint.DrawBorder(
g,
new Rectangle(0, 0, this.Width, this.Height),
borderColor,
_borderWidth,
ButtonBorderStyle.Solid,
borderColor,
_borderWidth,
ButtonBorderStyle.Solid,
borderColor,
_borderWidth,
ButtonBorderStyle.Solid,
borderColor,
_borderWidth,
ButtonBorderStyle.Solid);
g.Dispose();
}