2。在DataGrid中用事件
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); 得到选中的单元 }
}
怎么单元格就不能编辑了?有什么方法可以改变??
dataGridSPM.Select(hit.Row); 主要是它的问题!!
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); 得到选中的单元 }
}
怎么单元格就不能编辑了?有什么方法可以改变??
dataGridSPM.Select(hit.Row); 主要是它的问题!!
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);
}
}
而且配合CurrentCellChanged事件来用?
你是说我不该重载?没有重载之前也是这样的呀!?
我试了,还是不行!
yuwen16(rr)能说清楚点吗?谢谢!!
{
s=dataGrid1.CurrentCell.ColumnNumber;
dataGrid1.Select(dataGrid1.CurrentRowIndex);
}
在这个CurrentCellChanged事件中。调用dataGrid1_Click。