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);  主要是它的问题!!

解决方案 »

  1.   

    一个方法是:把COMBOBOX的数据源绑定到一个函数,绑定时向这个函数传递当前行的信息,然后在绑定函数中检索相应的数据内容返回数据源。
      

  2.   

    要能编辑,就注销掉
    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);
    }
    }
      

  3.   

    你为什么不写在click中?
    而且配合CurrentCellChanged事件来用?
      

  4.   

    tuzi98(兔子)
    你是说我不该重载?没有重载之前也是这样的呀!?
      

  5.   

    tuzi98(兔子)
    我试了,还是不行!
     yuwen16(rr)能说清楚点吗?谢谢!!
      

  6.   

    我只会你第二个问题,你需要得到选中的一列。 private void dataGrid1_Click(object sender, System.EventArgs e)
    {
    s=dataGrid1.CurrentCell.ColumnNumber;
    dataGrid1.Select(dataGrid1.CurrentRowIndex);
    }
    在这个CurrentCellChanged事件中。调用dataGrid1_Click。
      

  7.   

    不是选中的一列,是选中的那个Cell!!
      

  8.   

    COMBOBOX的数据源绑定到一个函数