怎样选择DataGrid中的一行?
解决方案 »
- winform label上字体过多不换行,字体自动缩放..
- RichtextBox 实现文本不可以选中,或代替RichtextBox显示数据
- net 里 加载 gif 等 动态 图片 的 方法
- 高分提问:[xxx()]是什么意义,是如何定义的,有什么作用
- windows Installer安装失败。。显示原版本和更新版本安装语言不同。。
- c# 怎样做漂亮的按扭
- 请教一个关于remoting双向通信的问题!
- Reporting service 中使用储存过程问题
- 请问,是否可以用EDITPLUS等文本编织缉工具来写C#,并编译?
- 怎么找不到ildasm啊?
- 如何在excel的单元格里进行换行阿?
- 总结一天的学习收获,学到的太少,经常处在迷茫中,怎样可以提高效率呀
if(hit.Type == DataGrid.HitTestType.Cell)
{
datagrid.Select(hit.Row);
if(datagrid.DataSource != null)
{
tmpDS = (DataSet)datagrid.DataSource;
DataRowView rowView = (DataRowView)datagrid.BindingContext[datagrid.DataSource,tmpDS.Tables[0].TableName].Current;
}
}
{
Point pt = new Point(e.X,e.Y);
DataGrid.HitTestInfo hit = dataGrid1.HitTest(pt);
if(hit.Type == DataGrid.HitTestType.Cell)
{
dataGrid1.Select(hit.Row);
}
}
Try
'''处理
If e.Button = MouseButtons.Left Then '左键点击
Me.gpbMoney.Focus() '转移焦点
Dim objHitTest As System.Windows.Forms.DataGrid.HitTestInfo 'DataGrid的点击信息
objHitTest = Me.grdMoney.HitTest(e.X, e.Y) '取得鼠标点击信息(列号,行号)
M_intRowIndex = -1 '初始化为-1
If objHitTest.Type <> DataGrid.HitTestType.None Then '点击不是空白处
If objHitTest.Row <> -1 Then '有选中的行索引
M_intRowIndex = objHitTest.Row '存放选中的行索引
End If
ElseIf objHitTest.Type = DataGrid.HitTestType.None Then '点击空白处
Me.grdMoney.UnSelect(Me.grdMoney.CurrentRowIndex) '取消选中当前行
End If
End If
'''异常处理
Catch ex As Exception
ProjectException.ShowErrMsg(Me.Name, "grdMoney_MouseDown", ex.Message)
End Try
End Sub
Private Sub grdMoney_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdMoney.MouseUp
Try
'''处理
If e.Button = MouseButtons.Left Then '左键UP
If M_intRowIndex >= 0 And M_intRowIndex <= Me.grdMoney.VisibleRowCount - 1 Then '索引在grdMoney是有效行索引
Me.grdMoney.Select(M_intRowIndex) '设置DataGride选中行
End If
End If
'''异常处理
Catch ex As Exception
ProjectException.ShowErrMsg(Me.Name, "grdMoney_MouseUp", ex.Message)
End Try
End Sub