大佬教程收集整理的这篇文章主要介绍了vb.net – datagridview cell,rowheader和columnheader的上下文菜单,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是一个示例MouseDown事件.要尝试该示例,请在表单上删除DataGridView和三个ContentMenuStrips.将ContentMenuStrips命名为mnuCell,mnuRow和mnucolumn.
Private Sub DataGridView1_MouseDown(ByVal sender As System.Object,ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown If e.button = Windows.Forms.MouseButtons.Right Then Dim ht As DataGridView.HitTesTinfo ht = Me.DataGridView1.HitTest(e.X,e.Y) If ht.Type = DataGridViewHitTESTTYPE.Cell Then DataGridView1.ContextMenuStrip = mnuCell mnuCell.Items(0).Text = String.Format("This is the cell at {0},{1}",ht.columnIndex,ht.RowIndeX) ElseIf ht.Type = DataGridViewHitTESTTYPE.RowHeader Then DataGridView1.ContextMenuStrip = mnuRow mnuRow.Items(0).Text = "This is row " + ht.RowIndex.ToString() ElseIf ht.Type = DataGridViewHitTESTTYPE.columnHeader Then DataGridView1.ContextMenuStrip = mnucolumn mnucolumn.Items(0).Text = "This is col " + ht.columnIndex.ToString() End If End If End Sub
在这里,我将DataGridView的ContextMenuStrip属性分配给适用于右键单击的项(单元格,行或列)的ContextMenuStrip.为了演示如何进一步自定义ContextMenuStrips的行为,我还在每个ContentMenuStrips的菜单项中设置文本.
以上是大佬教程为你收集整理的vb.net – datagridview cell,rowheader和columnheader的上下文菜单全部内容,希望文章能够帮你解决vb.net – datagridview cell,rowheader和columnheader的上下文菜单所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。