Winform dview hides columns and freeze windows in a pop-up window

Source: Internet
Author: User

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.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.