473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Flat Textbox

Hi,

I'm trying to create a textbox inheriting from the standard textbox. I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino

Sep 12 '06 #1
8 5047
Filipe,

Are you sure the propertie "borderstyle" does not help you.
http://msdn.microsoft.com/library/de...styletopic.asp

Cor
"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi,

I'm trying to create a textbox inheriting from the standard textbox. I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino

Sep 13 '06 #2
Hi Cor,

Has you may noticed I already set my textbox borderstyle to FixedSingle
(this.BorderStyle = BorderStyle.FixedSingle;). Now I want to paint that
border (black by default) with blue for example.

If I'm not being clear please make me know to clarify you.
Thanks in advance,
Filipe Marcelino

Cor Ligthert [MVP] wrote:
Filipe,

Are you sure the propertie "borderstyle" does not help you.
http://msdn.microsoft.com/library/de...styletopic.asp

Cor
"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi,

I'm trying to create a textbox inheriting from the standard textbox. I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino
Sep 13 '06 #3
Try adding this:

protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Refresh();
}

Seemed to fix the problem for me... though there is the problem of painting
the caret to deal with!

Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@e63g2000cwd.googlegr oups.com...
Hi Cor,

Has you may noticed I already set my textbox borderstyle to FixedSingle
(this.BorderStyle = BorderStyle.FixedSingle;). Now I want to paint that
border (black by default) with blue for example.

If I'm not being clear please make me know to clarify you.
Thanks in advance,
Filipe Marcelino

Cor Ligthert [MVP] wrote:
>Filipe,

Are you sure the propertie "borderstyle" does not help you.
http://msdn.microsoft.com/library/de...styletopic.asp

Cor
"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11*********************@m73g2000cwd.googlegr oups.com...
Hi,

I'm trying to create a textbox inheriting from the standard textbox. I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino

Sep 13 '06 #4
Hi Steve,

thanks for your reply but I tried and, in fact, the font doesn't "seems
to change" but it changes. Because we can see that, the caret, stays
way forward to the text. And, at some point, if we right text enough we
lose the sense of were we are writing... can you help me again?
Thanks,
Filipe Marcelino
Steve Barnett wrote:
Try adding this:

protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Refresh();
}

Seemed to fix the problem for me... though there is the problem of painting
the caret to deal with!

Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@e63g2000cwd.googlegr oups.com...
Hi Cor,

Has you may noticed I already set my textbox borderstyle to FixedSingle
(this.BorderStyle = BorderStyle.FixedSingle;). Now I want to paint that
border (black by default) with blue for example.

If I'm not being clear please make me know to clarify you.
Thanks in advance,
Filipe Marcelino

Cor Ligthert [MVP] wrote:
Filipe,

Are you sure the propertie "borderstyle" does not help you.
http://msdn.microsoft.com/library/de...styletopic.asp

Cor
"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi,

I'm trying to create a textbox inheriting from the standard textbox. I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino
Sep 13 '06 #5
I've tried but can't get the caret in the right place. To be honest though,
I think you're making a lot of work for yourself with this approach. If I
were to approach this problem, I'd go for creating a standard UserControl
with a text box in it:

partial class txtBox
{
private System.ComponentModel.IContainer components = null;

protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtTest = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtTest
//
this.txtTest.BorderStyle =
System.Windows.Forms.BorderStyle.None;
this.txtTest.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtTest.Location = new System.Drawing.Point(2, 2);
this.txtTest.Margin = new System.Windows.Forms.Padding(1);
this.txtTest.Multiline = true;
this.txtTest.Name = "txtTest";
this.txtTest.Size = new System.Drawing.Size(352, 23);
this.txtTest.TabIndex = 0;
this.txtTest.Text = "Test Text";
//
// txtBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.txtTest);
this.Name = "txtBox";
this.Padding = new System.Windows.Forms.Padding(1);
this.Size = new System.Drawing.Size(356, 27);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox txtTest;
}

Important thing to note is the padding on the user control (to give you room
to put the border) and the fact that the text box has no border and is
docked to fill the user control. This means that you don't have to handle
any of the painting of the text box, so won't have to deal with font sizes
or cope with the circumstance where your entered text is longer than the
text box (which your paint routine does not cope with now).

In the main body of the class, you'll need to provide accessors for the key
properties of the text box, but only for those that you desperately need,
such as the "Text" property and any events that you need to pass on.
(Alternatively, you can provide an accessot to get at the TextBox control).

public partial class txtBox : UserControl
{
public txtBox()
{
InitializeComponent();
}

public new string Text
{
get { return txtTest.Text; }
set { txtTest.Text = value; }
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
// Text box takes care of itself. We just paint our border.
e.Graphics.DrawRectangle(new System.Drawing.Pen(Color.Red), 1, 1,
Width-2, Height-2);
}

}

Obviously, you'll need to insert your logic for handling the mouse events. A
more complete set of code is:

public partial class txtBox : UserControl
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public txtBox()
{
InitializeComponent();

txtTest.MouseEnter += new EventHandler(OnMouseEnter);
txtTest.MouseLeave += new EventHandler(OnMouseLeave);
txtTest.MouseHover += new EventHandler(OnMouseHover);
txtTest.Enter += new EventHandler(OnEnter);
txtTest.Leave += new EventHandler(OnLeave);

}

public new string Text
{
get { return txtTest.Text; }
set { txtTest.Text = value; }
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(Color.Salmon), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(Color.Red), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
That would have been my approach, anyway.It may not be the most efficient
(I'm only a beginner here) but it means I don't have to reproduce any of the
functionality of a text box and I always like it when I don't have a lot of
complicated tuff to do!

HTH
Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi Steve,

thanks for your reply but I tried and, in fact, the font doesn't "seems
to change" but it changes. Because we can see that, the caret, stays
way forward to the text. And, at some point, if we right text enough we
lose the sense of were we are writing... can you help me again?
Thanks,
Filipe Marcelino
Steve Barnett wrote:
>Try adding this:

protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Refresh();
}

Seemed to fix the problem for me... though there is the problem of
painting
the caret to deal with!

Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@e63g2000cwd.googleg roups.com...
Hi Cor,

Has you may noticed I already set my textbox borderstyle to FixedSingle
(this.BorderStyle = BorderStyle.FixedSingle;). Now I want to paint that
border (black by default) with blue for example.

If I'm not being clear please make me know to clarify you.
Thanks in advance,
Filipe Marcelino

Cor Ligthert [MVP] wrote:
Filipe,

Are you sure the propertie "borderstyle" does not help you.
http://msdn.microsoft.com/library/de...styletopic.asp

Cor
"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11*********************@m73g2000cwd.googlegr oups.com...
Hi,

I'm trying to create a textbox inheriting from the standard textbox.
I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino


Sep 13 '06 #6
Steve,

I have a link to this, if it is to difficult, than please reply, than I will
see if I can set it to C#

http://www.vb-tips.com/dbpages.aspx?...0-58fd21b7e2ea

Cor

"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi Steve,

thanks for your reply but I tried and, in fact, the font doesn't "seems
to change" but it changes. Because we can see that, the caret, stays
way forward to the text. And, at some point, if we right text enough we
lose the sense of were we are writing... can you help me again?
Thanks,
Filipe Marcelino
Steve Barnett wrote:
>Try adding this:

protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Refresh();
}

Seemed to fix the problem for me... though there is the problem of
painting
the caret to deal with!

Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@e63g2000cwd.googleg roups.com...
Hi Cor,

Has you may noticed I already set my textbox borderstyle to FixedSingle
(this.BorderStyle = BorderStyle.FixedSingle;). Now I want to paint that
border (black by default) with blue for example.

If I'm not being clear please make me know to clarify you.
Thanks in advance,
Filipe Marcelino

Cor Ligthert [MVP] wrote:
Filipe,

Are you sure the propertie "borderstyle" does not help you.
http://msdn.microsoft.com/library/de...styletopic.asp

Cor
"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11*********************@m73g2000cwd.googlegr oups.com...
Hi,

I'm trying to create a textbox inheriting from the standard textbox.
I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino


Sep 13 '06 #7
Filipe
Just had a thought, you can make this even simpler by not overriding the
OnPaint event. Since all you're doing now is drawing the border in a
specific colour, all you need to do is set the background colour of the
UserControl to the border colour you want.

Because you have the 1 pixel margin, the background of the user control is
effectively your border around the text box. So, if you set the background
of the user control, your text box gets a 1 pixel border of that colour.

You can then dump the additional burden of overriding OnPaint. You don't
need to save the mouse state and don't need to Invalidate() the control.
Just set the background in the mouse events.

Just a thought.
Steve
"Steve Barnett" <no****@nodomain.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
I've tried but can't get the caret in the right place. To be honest
though, I think you're making a lot of work for yourself with this
approach. If I were to approach this problem, I'd go for creating a
standard UserControl with a text box in it:

partial class txtBox
{
private System.ComponentModel.IContainer components = null;

protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtTest = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtTest
//
this.txtTest.BorderStyle =
System.Windows.Forms.BorderStyle.None;
this.txtTest.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtTest.Location = new System.Drawing.Point(2, 2);
this.txtTest.Margin = new System.Windows.Forms.Padding(1);
this.txtTest.Multiline = true;
this.txtTest.Name = "txtTest";
this.txtTest.Size = new System.Drawing.Size(352, 23);
this.txtTest.TabIndex = 0;
this.txtTest.Text = "Test Text";
//
// txtBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.txtTest);
this.Name = "txtBox";
this.Padding = new System.Windows.Forms.Padding(1);
this.Size = new System.Drawing.Size(356, 27);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox txtTest;
}

Important thing to note is the padding on the user control (to give you
room to put the border) and the fact that the text box has no border and
is docked to fill the user control. This means that you don't have to
handle any of the painting of the text box, so won't have to deal with
font sizes or cope with the circumstance where your entered text is longer
than the text box (which your paint routine does not cope with now).

In the main body of the class, you'll need to provide accessors for the
key properties of the text box, but only for those that you desperately
need, such as the "Text" property and any events that you need to pass on.
(Alternatively, you can provide an accessot to get at the TextBox
control).

public partial class txtBox : UserControl
{
public txtBox()
{
InitializeComponent();
}

public new string Text
{
get { return txtTest.Text; }
set { txtTest.Text = value; }
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
// Text box takes care of itself. We just paint our border.
e.Graphics.DrawRectangle(new System.Drawing.Pen(Color.Red), 1, 1,
Width-2, Height-2);
}

}

Obviously, you'll need to insert your logic for handling the mouse events.
A more complete set of code is:

public partial class txtBox : UserControl
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public txtBox()
{
InitializeComponent();

txtTest.MouseEnter += new EventHandler(OnMouseEnter);
txtTest.MouseLeave += new EventHandler(OnMouseLeave);
txtTest.MouseHover += new EventHandler(OnMouseHover);
txtTest.Enter += new EventHandler(OnEnter);
txtTest.Leave += new EventHandler(OnLeave);

}

public new string Text
{
get { return txtTest.Text; }
set { txtTest.Text = value; }
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(Color.Salmon), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(Color.Red), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
That would have been my approach, anyway.It may not be the most efficient
(I'm only a beginner here) but it means I don't have to reproduce any of
the functionality of a text box and I always like it when I don't have a
lot of complicated tuff to do!

HTH
Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
>Hi Steve,

thanks for your reply but I tried and, in fact, the font doesn't "seems
to change" but it changes. Because we can see that, the caret, stays
way forward to the text. And, at some point, if we right text enough we
lose the sense of were we are writing... can you help me again?
Thanks,
Filipe Marcelino
Steve Barnett wrote:
>>Try adding this:

protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Refresh();
}

Seemed to fix the problem for me... though there is the problem of
painting
the caret to deal with!

Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@e63g2000cwd.google groups.com...
Hi Cor,

Has you may noticed I already set my textbox borderstyle to
FixedSingle
(this.BorderStyle = BorderStyle.FixedSingle;). Now I want to paint
that
border (black by default) with blue for example.

If I'm not being clear please make me know to clarify you.
Thanks in advance,
Filipe Marcelino

Cor Ligthert [MVP] wrote:
Filipe,

Are you sure the propertie "borderstyle" does not help you.
http://msdn.microsoft.com/library/de...styletopic.asp

Cor
"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11*********************@m73g2000cwd.googleg roups.com...
Hi,

I'm trying to create a textbox inheriting from the standard
textbox. I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when
editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino



Sep 13 '06 #8
Man....you said "(I'm only a beginner here)"!!!
You're a GENIUS beginner NO???? ehehehehhe
Thanks for everything!!!! I'll give it a try.
Many thanks,
Filipe Marcelino

Steve Barnett wrote:
Filipe
Just had a thought, you can make this even simpler by not overriding the
OnPaint event. Since all you're doing now is drawing the border in a
specific colour, all you need to do is set the background colour of the
UserControl to the border colour you want.

Because you have the 1 pixel margin, the background of the user control is
effectively your border around the text box. So, if you set the background
of the user control, your text box gets a 1 pixel border of that colour.

You can then dump the additional burden of overriding OnPaint. You don't
need to save the mouse state and don't need to Invalidate() the control.
Just set the background in the mouse events.

Just a thought.
Steve
"Steve Barnett" <no****@nodomain.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
I've tried but can't get the caret in the right place. To be honest
though, I think you're making a lot of work for yourself with this
approach. If I were to approach this problem, I'd go for creating a
standard UserControl with a text box in it:

partial class txtBox
{
private System.ComponentModel.IContainer components = null;

protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtTest = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtTest
//
this.txtTest.BorderStyle =
System.Windows.Forms.BorderStyle.None;
this.txtTest.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtTest.Location = new System.Drawing.Point(2, 2);
this.txtTest.Margin = new System.Windows.Forms.Padding(1);
this.txtTest.Multiline = true;
this.txtTest.Name = "txtTest";
this.txtTest.Size = new System.Drawing.Size(352, 23);
this.txtTest.TabIndex = 0;
this.txtTest.Text = "Test Text";
//
// txtBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.txtTest);
this.Name = "txtBox";
this.Padding = new System.Windows.Forms.Padding(1);
this.Size = new System.Drawing.Size(356, 27);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox txtTest;
}

Important thing to note is the padding on the user control (to give you
room to put the border) and the fact that the text box has no border and
is docked to fill the user control. This means that you don't have to
handle any of the painting of the text box, so won't have to deal with
font sizes or cope with the circumstance where your entered text is longer
than the text box (which your paint routine does not cope with now).

In the main body of the class, you'll need to provide accessors for the
key properties of the text box, but only for those that you desperately
need, such as the "Text" property and any events that you need to pass on.
(Alternatively, you can provide an accessot to get at the TextBox
control).

public partial class txtBox : UserControl
{
public txtBox()
{
InitializeComponent();
}

public new string Text
{
get { return txtTest.Text; }
set { txtTest.Text = value; }
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
// Text box takes care of itself. We just paint our border.
e.Graphics.DrawRectangle(new System.Drawing.Pen(Color.Red), 1, 1,
Width-2, Height-2);
}

}

Obviously, you'll need to insert your logic for handling the mouse events.
A more complete set of code is:

public partial class txtBox : UserControl
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public txtBox()
{
InitializeComponent();

txtTest.MouseEnter += new EventHandler(OnMouseEnter);
txtTest.MouseLeave += new EventHandler(OnMouseLeave);
txtTest.MouseHover += new EventHandler(OnMouseHover);
txtTest.Enter += new EventHandler(OnEnter);
txtTest.Leave += new EventHandler(OnLeave);

}

public new string Text
{
get { return txtTest.Text; }
set { txtTest.Text = value; }
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(Color.Salmon), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(Color.Red), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
That would have been my approach, anyway.It may not be the most efficient
(I'm only a beginner here) but it means I don't have to reproduce any of
the functionality of a text box and I always like it when I don't have a
lot of complicated tuff to do!

HTH
Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi Steve,

thanks for your reply but I tried and, in fact, the font doesn't "seems
to change" but it changes. Because we can see that, the caret, stays
way forward to the text. And, at some point, if we right text enough we
lose the sense of were we are writing... can you help me again?
Thanks,
Filipe Marcelino
Steve Barnett wrote:
Try adding this:

protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Refresh();
}

Seemed to fix the problem for me... though there is the problem of
painting
the caret to deal with!

Steve
"Filipe Marcelino" <fm********@gmail.comwrote in message
news:11**********************@e63g2000cwd.googleg roups.com...
Hi Cor,

Has you may noticed I already set my textbox borderstyle to
FixedSingle
(this.BorderStyle = BorderStyle.FixedSingle;). Now I want to paint
that
border (black by default) with blue for example.

If I'm not being clear please make me know to clarify you.
Thanks in advance,
Filipe Marcelino

Cor Ligthert [MVP] wrote:
Filipe,

Are you sure the propertie "borderstyle" does not help you.
http://msdn.microsoft.com/library/de...styletopic.asp

Cor
"Filipe Marcelino" <fm********@gmail.comschreef in bericht
news:11*********************@m73g2000cwd.googlegr oups.com...
Hi,

I'm trying to create a textbox inheriting from the standard
textbox. I
would like to:

1. repaint the textbox border;
2. define a color for that border;

Till now I made this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace Library.Controls
{
public class TextBox : System.Windows.Forms.TextBox
{
private enum MouseState
{
Focused,
Hoover,
Normal
}

private Color borderColor = Color.FromArgb(128, 128, 128);
//Gray
private Color highlightColor = Color.FromArgb(10, 36, 106);
//Blue
private Color hoverColor = Color.Silver; //Silver
private MouseState m_MouseState = MouseState.Normal;

public TextBox()
{
this.MouseEnter += new EventHandler(OnMouseEnter);
this.MouseLeave += new EventHandler(OnMouseLeave);
this.MouseHover += new EventHandler(OnMouseHover);
this.Enter += new EventHandler(OnEnter);
this.Leave += new EventHandler(OnLeave);
this.BorderStyle = BorderStyle.FixedSingle;

SetStyle(ControlStyles.UserPaint, true);

}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Text, Font, new
SolidBrush(ForeColor), new PointF(0, 0));

switch (m_MouseState)
{
case MouseState.Focused:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Hoover:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(highlightColor), 0, 0, Width - 1, Height - 1);
break;
case MouseState.Normal:
e.Graphics.DrawRectangle(new
System.Drawing.Pen(borderColor), 0, 0, Width - 1, Height - 1);
break;
}
}

#region Mouse Events
private void OnMouseEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
private void OnMouseLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}
private void OnMouseHover(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Hoover;
Invalidate();
}
#endregion

private void OnEnter(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Focused;
Invalidate();
}
private void OnLeave(object sender, System.EventArgs e)
{
m_MouseState = MouseState.Normal;
Invalidate();
}

}
}

The problem is related with the text drawing. Somehow, when
editing,
the textbox suddenlly uses other font then the default causing
missreading.

There's any way to solve this situation.
Thanks in advance for your attention,
Filipe Marcelino
Sep 13 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Nicolas Girard | last post by:
Hi, Forgive me if the answer is trivial, but could you tell me how to achieve the following: {k1:,k2:v3,...} --> ,,,...] The subtle point (at least to me) is to "flatten" values that are...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
13
by: raykyoto | last post by:
Hi all, I'm sure this is a popular question that comes up every few months here. Indeed, I've looked at some of the past postings, but I would like to ask things differently. Basically, I'm...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
1
by: Morten Wennevik | last post by:
Like a Button and RadioButton has a FlatStyle and a TextBox has a BorderStyle, is it possible to set a ComboBox to appear in the same way? No 3D borders. -- Using M2, Opera's revolutionary...
3
by: olivier | last post by:
I would like to know how to design a flat dropdownlist (border 1px solid) to use with asp.net (it seems no possible to modify this control's style unlike the textbox). thank's a lot
9
by: FFMG | last post by:
In my site I have a config table, (MySQL), with about 30 entries; the data is loaded on every single page load. This is not the only call to the db, (we do a total of about 8 calls to the db). As...
2
by: murthydb2 | last post by:
Hi My requirement is that i have to write a stored procedure in db2 and that will be executed in a batch file . Any system error or validation error that occurs inside the db2 sp during...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.