1. Small Window
Corresponding backgroundCode:
View code 1 Public Partial Class Hidecolumn: Form
2 {
3 Public Datagridview dgv { Set ; Get ;}
4
5 Public Hidecolumn ()
6 {
7 Initializecomponent ();
8 }
9
10 Private Void Btnhidecolumn_click ( Object Sender, eventargs E)
11 {
12 Dgv. Columns [ 3 ]. Visible = False ;
13 }
14 }
2. In the window containing the datagridview
When you click showhidecolumn, the operation code is as follows:
View code 1 Private Void Showhid1_lstripmenuitem_mousedown ( Object Sender, mouseeventargs E)
2 {
3 Hidecolumn HC = New Hidecolumn ();
4 HC. dgv = Datagridview1;
5 HC. Visible = True ;
6
7 }
The code for the pop-up window with a mode dialog box is as follows:
View code 1 Private Void Showhid1_lstripmenuitem_mousedown ( Object Sender, mouseeventargs E)
2 {
3 Hidecolumn HC = New Hidecolumn ();
4 HC. dgv = Datagridview1;
5 HC. showdialog ();
6
7 }
2. The code for freezing the window is as follows. Code appears in a small window
The Code is as follows:
View code 1 Private Void Btnsure_click ( Object Sender, eventargs E)
2 {
3 Int Rownum = Convert. toint32 (tbrownum. Text );
4 Int Columnnum = Convert. toint32 (tbcolumnnum. Text );
5 If (Rownum > = 0 && Rownum < Dgv. Rows. Count)
6 {
7 Dgv. Rows [rownum]. Frozen = True ;
8
9 }
10 If (Columnnum > = 0 && Columnnum < Dgv. Columns. Count)
11 {
12 Dgv. Columns [columnnum]. Frozen = True ;
13 }
14 }
Purpose: set the permissions that some users can access.