Research two the first project to be done next semester (some notes about DataGridView)

Source: Internet
Author: User

First, row header column Rowheader

DataGridView1.TopLeftHeaderCell.Value = "Details";

_______________________________________________________

Sometimes when you manually add columns in the DataGridView, even if you adjust the order of the columns by the up and down arrows, the order of the columns does not appear when you run them.

I manually added the Datagridviewcomboboxcolumn column in DataGridView, and no matter how the adjustment is shown in the last column each time, the displayindex of using the column in the code is not working.

Then I used the autogeneratecolumns=false to do it. The value defaults to true.

_______________________________________________________

The column's index cannot be changed with strongly typed datasets, regardless of the order in which the columns are adjusted with the SELECT statement. The index of the column is only relevant to the index of the column in the database table.

Using a common dataset (such as a DataTable dataset) can change the index of a column by using the SELECT statement to adjust the order of the columns.

DataTable dt1 = new DataTable ("Tblstudemo");
String sql = "Select Age,id, name from Tblstudemo";

String sql = "Select ID, Name, age from Tblstudemo";
String connstring = @ "";
SqlDataAdapter ada1 = new SqlDataAdapter (SQL, connstring);
Ada1. Fill (DT1);

_______________________________________________________

I manually added the Datagridviewcomboboxcolumn column in DataGridView and added {"Thick", "large", "medium"} to the data table with the Items collection, and the column is in the database type nchar (10).

Then the program has been an error. As the DataError incident has been rewritten by me, it is difficult to find the crux of the matter. Finally, the Sand grain column type is changed to nchar (1) before it is finally settled. Be sure to pay attention to type matching.

_______________________________________________________

So much for the first ...

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.