G
giddy
hi when i run this class i made here , this is what it looks like
without text - > http://gidsfiles.googlepages.com/LinedTextBox_1.jpg
WITH TEXT (heres the issue) -
http://gidsfiles.googlepages.com/LinedTextBox_withText.jpg
The text turns BOLD and the lines kinda get erased because of the text.
perhaps i could overide or handle the onKeydown or somethin and
intercept the text to be entered and then draw it myself. Any
suggestions????????
this is the code :
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace Linedtextbox
{
class LinedTextBox : System.Windows.Forms.TextBox
{
public LinedTextBox(): base()
{
Multiline = true;
SetStyle(System.Windows.Forms.ControlStyles.UserPaint,true);
}
protected override void
OnPaint(System.Windows.Forms.PaintEventArgs e)
{
int txtHeight = Convert.ToInt32(Font.GetHeight()) + 3;
Pen thePen = new Pen(Color.Black);
for (int i = txtHeight; i < Height ; i += txtHeight)
{
e.Graphics.DrawLine(thePen, 0, i, this.Width, i);
}
base.OnPaint(e);
}
}
}
Gideon
without text - > http://gidsfiles.googlepages.com/LinedTextBox_1.jpg
WITH TEXT (heres the issue) -
http://gidsfiles.googlepages.com/LinedTextBox_withText.jpg
The text turns BOLD and the lines kinda get erased because of the text.
perhaps i could overide or handle the onKeydown or somethin and
intercept the text to be entered and then draw it myself. Any
suggestions????????
this is the code :
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace Linedtextbox
{
class LinedTextBox : System.Windows.Forms.TextBox
{
public LinedTextBox(): base()
{
Multiline = true;
SetStyle(System.Windows.Forms.ControlStyles.UserPaint,true);
}
protected override void
OnPaint(System.Windows.Forms.PaintEventArgs e)
{
int txtHeight = Convert.ToInt32(Font.GetHeight()) + 3;
Pen thePen = new Pen(Color.Black);
for (int i = txtHeight; i < Height ; i += txtHeight)
{
e.Graphics.DrawLine(thePen, 0, i, this.Width, i);
}
base.OnPaint(e);
}
}
}
Gideon