To TheAres(班门斧) 一个DataGrid问题!
我引用了你的程序:
#region class DataGridEnableTextBoxColumn
public class DataGridEnableTextBoxColumn:System.Windows.Forms.DataGridTextBoxColumn
{
private int _col;
public delegate void EnableCellEventHandler(object sender,DataGridEnableEventArgs e);
public DataGridEnableTextBoxColumn()
{
}
public event EnableCellEventHandler CheckCellEnabled;
protected override void Paint(Graphics g,Rectangle rc,CurrencyManager cm,int rowNumber,Brush backbrush,Brush forebrush,bool LtoR)
{
bool enabled = true;
DataGridEnableEventArgs e = new DataGridEnableEventArgs(rowNumber,_col,enabled);
CheckCellEnabled(this,e);
backbrush = new System.Drawing.SolidBrush(e.BackColor);
base.Paint(g,rc,cm,rowNumber,backbrush,forebrush,LtoR);
}
protected override void Edit(CurrencyManager source,int rowNum,Rectangle bounds,bool OnlyRead,string instantText,bool cellIsVisible)
{
bool enabled = true;
DataGridEnableEventArgs e = new DataGridEnableEventArgs(rowNum,_col,enabled);
this.CheckCellEnabled(this,e);
if (e.EnableValue)
{
base.Edit(source,rowNum,bounds,OnlyRead,instantText,cellIsVisible);
}
}
其中对Paint重载过后与
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point pt = new Point(e.X,e.Y);
DataGrid.HitTestInfo hit = dataGridSPM.HitTest(pt);
if(hit.Type == DataGrid.HitTestType.Cell)
{
dataGridSPM.Select(hit.Row);
//dataGridQDSYB.CurrentCell = new DataGridCell(hti.Row, hti.Column); 得到选中的单元
}
}
好象有冲突???
也就是我设定具有特定值的行有特定的颜色后,我再有鼠标点击任一行想让他高亮显示,结果不行,并且单元格里边的文本看不见了!!??你能帮我看看是什么问题吗?注销backbrush = new System.Drawing.SolidBrush(e.BackColor);就可以了,但又不能设定颜色了!!(万分感谢)