Ah but sure it can be done. I had the same problem and came up with the
following solution. You create a textbox inherited from a "normal"
textbox. In that textbox control, you override the OnPaint method. This is
C#. I have the same example in VB, but not on the computer I'm currently
working on. But this should give you the general idea.
using System;
using System.Drawing;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
namespace UserControls
{
[ToolboxBitmap(typeof(System.Windows.Forms.TextBox))]
public partial class FoBTextBox : TextBox
{
protected override void OnPaint(PaintEventArgs e)
{
//First paint the control normally
base.OnPaint(e);
//Set new brush - Black in this case
SolidBrush brush = new SolidBrush(ForeColor);
//Draw text
e.Graphics.DrawString(Text, Font, brush, 0f, 1f);
//Dispose of brush
brush.Dispose();
}
private void OnFoBTextBox_EnabledChanged(object sender, EventArgs e)
{
if (this.Enabled)
{
//BackColor for enabled textbox
this.BackColor = System.Drawing.SystemColors.Window;
}
else
{
//BackColor for disabled textbox
this.BackColor = System.Drawing.SystemColors.InactiveBorder;
}
//Set textbox style to userpaint
this.SetStyle(ControlStyles.UserPaint, !this.Enabled);
//Invalidate to paint the control
this.Invalidate();
}
}
}
Good luck,
Johnny J.
Rob said:
Ok, I will buy that... but there still appears to be no way to turn off
the "grey out attribute" when a textbox is not enabled....
Thanks...