C # datagridview,form Common Properties Summary

Source: Internet
Author: User

1. Remove the DataGridView boot column (indicating the column where the arrow is)

Two attributes: Rowheadersvisible = false; Columnheadersvisibele = False

2. Select a row for DataGridView instead of a cell

Set Property SelectionMode to Fullrowselect

3. Set the GridView all columns to populate the parent layout:

Datagridview1.autosizecolumnsmode = Datagridviewautosizecolumnsmode.fill;

4. The setup form is displayed in the middle of the computer screen:

This. StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

5.form Add Key_down event, press no response.

You need to set the value of the KeyPreview property in form to True

6. Prohibit users from changing DataGridView row, column height

DataGridView Properties: Allowusertoresizerows and Allowusertoresizecolumns set to False

7. Hide the DataGridView Cell box:

The Cellborderstyle property is set to None

8. Set a column to display a red font:

The third column is set to red font roomgridview.columns[2]. Defaultcellstyle.forecolor = color.red; 9. Set column header not clickable sort:

for (int i = 0; i < RoomGridView.Columns.Count i++) {//Set header click Sort function Not available Roomgridview.columns[i].                 SortMode = datagridviewcolumnsortmode.notsortable; } 10. To set a column cell text to center display:

Set second column cell contents centered

ROOMGRIDVIEW.COLUMNS[1]. Defaultcellstyle.alignment = Datagridviewcontentalignment.middlecenter;

11.c# add an underscore column to use the Datagridviewlinkcolumn column, when manually added, to display the text, add properties: datagridviewlinkcolumn LC = new Datagridviewlinkcolumn ();
Lc.             Name = "TEST"; Lc.             Text = "Test"; Lc. HeaderText = "Modify"; Lc. Usecolumntextforlinkvalue = true; 12. Modify Row Height:

The Height property under the Rowtemplate property.

13. Set column headings in the middle, sometimes not fully centered, but the left side of the solution:

Deep copy in 14.c#:

The 15.c# ToolTip property is used to implement the mouse hover prompt text effect.

16. Draw Split Line:

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.