C # dataGrid uses small TIP (1)

zhaozj2021-02-16  90

C # dataGrid uses small TIP (1)

Keywords: C # dataGrid We sometimes encounter such problems when using DataGrid: ????? Assumption DataGrid? Binding is a list of data fields in one of the bindings? Is it TEacher? Indicates whether the teacher is The value may be 0 or 1, then what we want is "No" if the value is 0 when the value is 0, if the value is 1 display "Yes". ????? Then we can make the following conversion when the data source is bound to DataGrid: ????????????????????????????????????????? Private void DataGrid1_itemDatabase (Object Sender, System.DataGriditeMeventArgs E) { ??? DataGridItem item = e.Item; ??? ListItemType itemType = e.Item.ItemType;!!! ?????? if (itemType = ListItemType.Header && itemType = ListItemType.Footer && itemType = istItemType.Separator ) {???? switch (item.cells [3] .Text.trim ()) {????? case "0": ??????? item.cells [3] .text = "No "; ?????? Break; ????? case" 1 ": ?????? Item.cells [3] .Text =" Yes "; ?????? Break; ??? ?? Default: ???????????? Break; ????} ???} ???} (assuming: isteacher? Binding in the fourth column.) Know the function name This code is the execution code of DataGrid1 ItemDatabase. You only need to find DataGrid1 ItemDatabase in the event, the system will automatically bind the commission of the event.

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

New Post(0)