Winform C # FAQs about using the datagridview

Source: Internet
Author: User
/// Autosizecolumnsmode specifies how to set the column width
// Setgridview. autosizecolumnsmode = maid;
//// Autosizerowsmode specifies how to set the Row Height
// Setgridview. autosizerowsmode = maid;

//// You can adjust the width of the column title as needed.
// Setgridview. columnheadersheightsizemode = maid. autosize;
/// You can adjust the width of the row title as needed.
// Setgridview. rowheaderswidthsizemode = maid. autosizetoallheaders;

// Datagridviewcheckboxcolumn column = new datagridviewcheckboxcolumn ();
// Setgridview. Columns. insert (0, column );

// Column Title text center columns in the datagridviewcolumn Control
foreach (datagridviewcolumn Col in setgridview. columns)
{< br> Col. sortmode = maid. notsortable;
}< br> setgridview. columnheadersdefaultcellstyle. alignment = maid. middlecenter;

// Row Height rows in the datagridviewrow Control
foreach (maid rows in setgridview. rows)
{< br> rows. height = 15;
}

// Click Select the entire row selectionmode to specify how to set the cell datagridviewselectionmode
Setgridview. selectionmode = maid mode. fullrowselect; // fullrowselect selects the entire row by clicking the header and the contained cells
// Set not to display the leftmost column of dategridview
Setgridview. rowheadersvisible = false;

// Return the data of any cell in the selected row in the datagridview Control
Return setgridview. currentcell. owningrow. cells [0]. value. tostring ();

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.