My Usercontrol behaves different in VS2010 and VS 2013
-
Hi all, In my c# windows forms project I Have a user control. I have some code to create a blue border when clicked. If I debug my project in VS2013 all is working, but in VS 2010 express the color does not change! Both VS versions target the .NET framework 4. If I open my project directly in bin/Debug/ .exe it is not working. In bin/Release/ .exe it is working. This is the relevant code:
private Control currentCsKeypadControl;
public FormUserMain()
{
InitializeComponent();foreach (Control tb in tableLayoutPanelCsKeypad.Controls) { if (tb.GetType() == typeof(MyControl)) { MyControl control = tb as MyControl; { control.Click += delegate(object sender, EventArgs eventArgs) { tb.BackColor = Color.Blue; timerKeyColor.Start(); currentCsKeypadControl = sender as MyControl; currentCsKeypadControl.Invalidate(); }; } } } }
private void timerKeyColor_Tick(object sender, EventArgs e)
{timerKeyColor.Stop(); if(!timerKeyColor.Enabled) currentCsKeypadControl.BackColor = Color.Transparent; }
public class MyControl : Label
{
Image _image = null;public MyControl() { // Allow transparent background SetStyle(ControlStyles.SupportsTransparentBackColor, true); // Default to transparent background this.BackColor = System.Drawing.Color.Transparent; } public Image Image { get { return \_image; } set { \_image = value; } } protected override void OnPaint(PaintEventArgs e) { if (this.Image != null) { // Draw image smaller to create border with back color. e.Graphics.DrawImage(this.Image, 3, 3, this.Width - 6, this.Height - 6); } RectangleF rectangle = new RectangleF(2, 0, this.Width, this.Height + 5); StringFormat format = new StringFormat(); format.LineAlignment = StringA
-
Hi all, In my c# windows forms project I Have a user control. I have some code to create a blue border when clicked. If I debug my project in VS2013 all is working, but in VS 2010 express the color does not change! Both VS versions target the .NET framework 4. If I open my project directly in bin/Debug/ .exe it is not working. In bin/Release/ .exe it is working. This is the relevant code:
private Control currentCsKeypadControl;
public FormUserMain()
{
InitializeComponent();foreach (Control tb in tableLayoutPanelCsKeypad.Controls) { if (tb.GetType() == typeof(MyControl)) { MyControl control = tb as MyControl; { control.Click += delegate(object sender, EventArgs eventArgs) { tb.BackColor = Color.Blue; timerKeyColor.Start(); currentCsKeypadControl = sender as MyControl; currentCsKeypadControl.Invalidate(); }; } } } }
private void timerKeyColor_Tick(object sender, EventArgs e)
{timerKeyColor.Stop(); if(!timerKeyColor.Enabled) currentCsKeypadControl.BackColor = Color.Transparent; }
public class MyControl : Label
{
Image _image = null;public MyControl() { // Allow transparent background SetStyle(ControlStyles.SupportsTransparentBackColor, true); // Default to transparent background this.BackColor = System.Drawing.Color.Transparent; } public Image Image { get { return \_image; } set { \_image = value; } } protected override void OnPaint(PaintEventArgs e) { if (this.Image != null) { // Draw image smaller to create border with back color. e.Graphics.DrawImage(this.Image, 3, 3, this.Width - 6, this.Height - 6); } RectangleF rectangle = new RectangleF(2, 0, this.Width, this.Height + 5); StringFormat format = new StringFormat(); format.LineAlignment = StringA
Have you tried "cleaning" the project and rebuilding it?
The difficult we do right away... ...the impossible takes slightly longer.
-
Have you tried "cleaning" the project and rebuilding it?
The difficult we do right away... ...the impossible takes slightly longer.
Thank You Richard your suggestion worked. Thanks, Groover
0200 A9 23 0202 8D 01 80 0205 00