Summary of some small features in C #, Java (continuous update ...)

Source: Internet
Author: User

Foreword: In the project, sometimes some small function point, always easy to let people neglect, but these functions add in the project often very useful, so the author here summarizes some practical small function points encountered in the project, to spare, and continuously updated ...

1. Disable the DataGridView header sorting function

1        /// <summary>2         ///No click on the list header to sort3         /// </summary>4         /// <param name= "DGV" >Current DataGridView Control</param>5         Private voidDisablesortorder (DataGridView DGV)6         {7              for(inti =0; I < DGV. ColumnCount; i++)8             {9DGV. Columns[i]. SortMode =datagridviewcolumnsortmode.notsortable;Ten             } One}

2. Shield double-click the title bar window to be smaller, click the title bar to move the window event

1         /// <summary>2         ///block Double-click the title bar to small events, click the title bar to move window events3         /// </summary>4         /// <param name= "M" ></param>5         protected Override voidWndProc (refMessage m)6         {7             //Double-click the title bar, move window events8             if(M.msg! =0xa3&& m.msg! =0x0003&& M.wparam! = (INTPTR)0xf012)9             {Ten                 Base. WndProc (refm); One             } A  -}

Note: In the need to not be moved in the window to add the above code, other specific messages, can query the relevant information, to control.

m.msg = 0xa3 Double-click title Bar Message

m.msg = 0x0003 && M.wparam = (IntPtr) 0xf012, mobile form messages

3. When you log in, close the login window when the password is entered correctly

Note: This function is actually more important, because if we directly this.hide () or this.close () is not possible, it is required a small skill to control, the following code:

1. In Program.cs, the following:

1  New loginform (); 2 LF. ShowDialog (); 3  if (LF.) DialogResult = = DialogResult.OK)4       Application.Run (new selectitemform ());

2. Then in the Login window, when the login is successful, the following control:

This. DialogResult = DialogResult.OK;
This. Close ();

With the above two steps, you can turn off the login interface to the desired main interface.

Continuous update ... by Shawn Chen 2017.7.10 Night

Summary of some small features in C #, Java (continuous update ...)

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.