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 ...)