怎么让 datagrid 的某个row 获取焦点 select 是选中选中后怎么获得焦点,谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 this.dataGrid1.CurrentRowIndex=this.ds.Tables [0].Rows .Count; 气死我了 this.dataGrid1.CurrentRowIndex=this.ds.Tables [0].Rows .Count; 是肯定不对的 关注中 sample code as follows:yourDataGrid.Select( yourRowIndex ); to 选中后怎么获得焦点,谢谢了yourDataGrid.CurrentCell = new DataGridCell( yourRowIndex, yourColumnIndex); yourDataGrid.CurrentCell = new DataGridCell( yourRowIndex, yourColumnIndex); yourDataGrid.Focus();Row是沒有焦點的﹐真正獲取焦點的是Cell對應的Col的DataGridTextBox也可以直接將DataGrid的CurrentRowIndex設為yourRowIndex,這本身是沒有錯的﹐如果有錯﹐就是你的DataTable的DefaultView排序和DataGrid的排序不一樣照成的.如果你的DataGrid支持排序﹐且已重新排序(就是點擊了表頭)﹐再想定位﹐就很麻煩了。只能遍歷了. 参考这里的实现,http://blog.csdn.net/zhzuo/archive/2004/05/31/22036.aspx 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; datagrid1.select(你要获得焦点行的行号int型的) to:请问怎么改变选中的行的表格颜色?自己定义一个DataGrid样式,然后通过事件控制 新浪微博C# SDK Demo运行时报错 关于sendMessage 急!!!C#如何讓webBrowser控件有mouseEnter事件? [原创小技巧]WINFORM开发小技巧三则 非常简单vs2008窗体设计的小问题 如何用C#实现在两台显示器间切换 如何计算某种字体的半角空格及字符串的宽度?(.net2005 winform)急~~~~~ textbox绑定数据并可以通过按钮显示下一条?谢谢 如何用C#在windows应用程序中发送邮件。 一个简单的打印关题 关于datagrid里添加按钮的问题 帮忙修改DataGrid 编辑问题!!有代码```求修改```
气死我了
yourDataGrid.Select( yourRowIndex );
yourDataGrid.CurrentCell = new DataGridCell( yourRowIndex, yourColumnIndex);
yourDataGrid.Focus();
Row是沒有焦點的﹐真正獲取焦點的是Cell對應的Col的DataGridTextBox
也可以直接將DataGrid的CurrentRowIndex設為yourRowIndex,這本身是沒有錯的﹐如果有錯﹐就是你的DataTable的DefaultView排序和DataGrid的排序不一樣照成的.
如果你的DataGrid支持排序﹐且已重新排序(就是點擊了表頭)﹐再想定位﹐就很麻煩了。只能遍歷了.
http://blog.csdn.net/zhzuo/archive/2004/05/31/22036.aspx
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;
自己定义一个DataGrid样式,然后通过事件控制