白色间距datagrid视图 [英] White spacing datagrid view

查看:65
本文介绍了白色间距datagrid视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个带有几行的datagridview。我想避免用户点击空白区域(行后空白区域)



或者至少我可以在用户点击空白区域时捕获,所以可能是一条消息显示。



请告知如何操作。



谢谢

Hi,
I have a datagridview with a few rows. I want to refrain user from clicking the white spaces (empty area after rows)

Or at least I could catch when user clicks the empty area, so a message could be displayed.

Please advise how to do it.

Thanks

推荐答案

如果您在行之后讨论网格内的空白区域,则将网格的AutoSizeColumnsMode属性设置为FILL。然后列将自动调整为gridview宽度。



如果你在谈论一个空单元格,那么 -

If you are talking about the empty area inside the grid after rows then set AutoSizeColumnsMode property of grid to FILL. then columns will be auto sized to gridview width.

If you are talking about an empty cell then -
Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
    Dim MyVal As String = DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString
    If String.IsNullOrWhiteSpace(MyVal) Then
        MsgBox("You click on empty cell")
    End If
End Sub


这篇关于白色间距datagrid视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆