如何在datagridview的当前单元格中(靠一边)显示一个命令按钮?
当在datagridview的一个单元格获得焦点时,在单元格的一边显示一个命令按钮,当焦点离开该单元格时,命令按钮不显示,如何实现这个功能,请各位高手出手相助,不吝赐教,在下不胜感激!
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick If e.ColumnIndex = -1 Or e.RowIndex = -1 Then Exit Sub Dim a As New Button Dim GetRect As New Rectangle GetRect = DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True) Me.DataGridView1.Controls.Add(a) a.Text = "修改" a.SetBounds(GetRect.Left + GetRect.Width * 2 / 3, GetRect.Top, GetRect.Width / 3, GetRect.Height) a.Show() End Sub