To TheAres(班门斧) 一个DataGrid问题!

bh2001zhh 2003-04-06 07:24:53
我引用了你的程序:
#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);就可以了,但又不能设定颜色了!!(万分感谢)

...全文
23 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bh2001zhh 2003-04-08
  • 打赏
  • 举报
回复
怎么没人理我??!!
bh2001zhh 2003-04-07
  • 打赏
  • 举报
回复
有人能解决一下么?是分太少??

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧