C # Form layout Details _c# tutorial

Source: Internet
Author: User

DataGridView:

Displaying data tables

Background Data binding:

list<xxx> list = new list<xxx> ();
Datagridview1.datasource = list;

Setting does not automatically generate columns, this property is not in the properties panel

Datagridview1.autogeneratecolumns = false;

Cancel load Default Check first row

Datagridview1.clearselection ();

Front desk:

Small triangle arrow, cancel editable, add, delete function;

    1. Columns collection properties, adding columns
    2. Set the text displayed in HeaderText
    3. DataPropertyName sets the field name or database column name of the binding
    4. SelectionMode--Set the selection mode, Fullrowselect can only select rows
    5. MultiSelect--Can I select multiple lines of content

Take value:

Remove the value of the selected cell:

All selected cells are placed in the Datagridview1.selectedcells
if (DataGridView1.SelectedCells.Count > 0)
{
MessageBox.Show (Datagridview1.selectedcells[0]. Value.tostring ());
}

To remove the selected row contents:

if (DataGridView1.SelectedRows.Count > 0)
{
MessageBox.Show (datagridview1.selectedrows[0). Cells[0]. ToString ());
}

Gets the object used to populate the row bindings:

Row objects using attributes: Databounditem

Student SSS = Datagridview1.selectedrows[0]. Databounditem as student;

Dock property:

1.Top: Top, height unchanged, left/right (width) stretch
2.Bottom: Down, height unchanged, stretching left and right
3.Fill: Fill the entire area
4.Left: Left, width unchanged, up and down stretch
5.Right: Right, width unchanged, stretching up and down

Through this article, I hope to help you learn this part of knowledge, thank you all for the support of this site!

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.