Home > Software engineering >  DataGridView columns show and hide functions
DataGridView columns show and hide functions

Time:10-02

Renderings are as follows:


As long as the DataGridView control right click on the top left hand corner, will appear in the right-click CheckBoxList, CheckBoxList of each item is a DataGridView column names, by default, all items will be selected to cancel an item is selected, the corresponding column will hide, if selected, the corresponding column will be displayed,

How to write in the VB code, please? Thank you for your prawn

CodePudding user response:

I depend, no one know?

CodePudding user response:

With a picturebox, just used the DataGridView

CodePudding user response:

Used DataGridView, below is the search code can determine click the position, you can use a picturebox etc. It is ok to simulate the:
 Dim rowNum, columnNum As Integer 'were line and column number 
Private Sub DataGrid1_MouseDown (ByVal sender As Object, ByVal e the As System. Windows, Forms the MouseEventArgs) Handles DataGrid1. The MouseDown
Dim myGrid As DataGrid=CType (sender, the DataGrid)
Dim hti As System. Windows. Forms. The DataGrid. HitTestInfo
Hti=myGrid. HitTest (e.X, e.Y)
If e.B utton=MouseButtons. Right And licks=1 Then of e.c. with our fabrication: 'If it is the mouse Right click on the
The Select Case hti. Type '
Case System. Windows. Forms. The DataGrid. HitTestType. Cell, System. Windows. Forms. The DataGrid. HitTestType. RowHeader, System. Windows. Forms. The DataGrid. HitTestType. ColumnHeader
RowNum=hti. Row 'get the mouse right click on the Row of
ColumnNum=hti. The Column 'get the mouse right click on the Column where
End the Select
End the If
End Sub


CodePudding user response:

Baidu to address: http://www.wzsky.net/html/program/net/28454.html, look at yourself
  • Related