select 是选中选中后怎么获得焦点,谢谢了

解决方案 »

  1.   

    this.dataGrid1.CurrentRowIndex=this.ds.Tables [0].Rows .Count; 
    气死我了
      

  2.   

    this.dataGrid1.CurrentRowIndex=this.ds.Tables [0].Rows .Count;  是肯定不对的 关注中
      

  3.   

    sample code as follows:
    yourDataGrid.Select( yourRowIndex );
      

  4.   

    to 选中后怎么获得焦点,谢谢了
    yourDataGrid.CurrentCell = new DataGridCell( yourRowIndex, yourColumnIndex); 
      

  5.   

    yourDataGrid.CurrentCell = new DataGridCell( yourRowIndex, yourColumnIndex); 
    yourDataGrid.Focus();
    Row是沒有焦點的﹐真正獲取焦點的是Cell對應的Col的DataGridTextBox
    也可以直接將DataGrid的CurrentRowIndex設為yourRowIndex,這本身是沒有錯的﹐如果有錯﹐就是你的DataTable的DefaultView排序和DataGrid的排序不一樣照成的.
    如果你的DataGrid支持排序﹐且已重新排序(就是點擊了表頭)﹐再想定位﹐就很麻煩了。只能遍歷了.
      

  6.   

    参考这里的实现,
    http://blog.csdn.net/zhzuo/archive/2004/05/31/22036.aspx
      

  7.   

    System.Windows.Forms.DataGrid.HitTestInfo myHitTest;
    myHitTest = this.showDataGrid.HitTest(e.X,e.Y);
    int row=myHitTest.Row;
    if(row<0||row>this.showDataGrid.VisibleRowCount)
    {
    row=this.showDataGrid.CurrentRowIndex;
    }
    this.showDataGrid.UnSelect(this.showDataGrid.CurrentRowIndex);
    this.showDataGrid.CurrentRowIndex=row;
    this.showDataGrid.Select(this.showDataGrid.CurrentRowIndex);
    this.showDataGrid.ContextMenu=this.contextMenu1;
      

  8.   

    datagrid1.select(你要获得焦点行的行号int型的)
      

  9.   

    to:请问怎么改变选中的行的表格颜色?
    自己定义一个DataGrid样式,然后通过事件控制