Small problem set (1)

xiaoxiao2021-03-05  21

1. When the dataGrid binding data in WinForm, the list of DataGrid usually is the same as the field name of the table; if you don't want this, how to solve it? For example: the field name is English (or pinyin), how to display these in Chinese List head?

2. Mysql's Chinese display problem.

3. How to dynamically add a menu and add a response event to it?

4. How to right-click the custom menu

Question 1 answer:

After reading data from the database to the DataGrid, the column header of the DataGrid is usually the same as the field name of the database. If you do not want this, you can use the list and column mapping technology: use system.data.common;

String strsql = "select * from department"; OLEDBDataAdapter Adapter = New OLEDBDataAdapter (strsql, conn);

DataTableMapping DTMDEP = adapter.tablemappings.add ("Department", "Department Table");

DTMDEP.COLUMNMAPPINGS.ADD ("DEP_ID", "Department Number"); DTMDEP.COLUMNMAPPINGS.ADD ("Dep_name", "Department Name");

DataSet DS = New DataSet ();

Adapter.Fill (DS, "Department"); // Can't use "department table" here

Response Click Event (DataGrid's CurrentCellchange DataGridName.currentcell.columnname.currentcell.columnnumber; // Click the subscript, starting from 0, the next DataGridName.currentcell.rownumber; // Single Run Data DataGridName [datagridname .Currentcell]; // 所 单 行行 and column value

DataGridName [datagridname.currentrowindex, n] .tostring (); // Get the value of the Northern N 1 column

转载请注明原文地址:https://www.9cbs.com/read-38060.html

New Post(0)