c# - How do I create a datagrid with a string field and a combobox in one of the columns -


i have created wpf application , calling window display database table fieldnames. using datagrid display field names. second column of datagrid combobox items "include" , "exclude". know how datagrid , display field names. cannot figure out how this. not know go here.

my xml far looks this:

<datagrid headersvisibility="column" isreadonly="true" itemssource="{binding}" name="dtgrid" loaded="gridloaded" width="283" horizontalalignment="left" verticalalignment="top" height="365" margin="54,74,0,0" borderthickness="1" borderbrush="black">         <datagrid.columns>             <datagridtextcolumn x:name="fieldname" header="field name" width="180" />             <datagridcomboboxcolumn x:name="comboboxcolumn" width="83" header="include field" selecteditembinding="{binding strfieldinclude}" />         </datagrid.columns>     </datagrid> 

my code attempt looks this:

private void displayfields(string[] stringfieldnames)     {         int intdisplaycnt, inttotalrowsize = 0;         string strdata, strfieldsize = "";          datatable dt = new datatable();         dt.columns.add("fieldname", typeof(string));          //datatable dt = (datatable)dtgrid.itemssource;          (intdisplaycnt = 0; intdisplaycnt < stringfieldnames.length; intdisplaycnt++)         {             dt.rows.add(stringfieldnames[intdisplaycnt]);         }          dtgrid.itemssource = dt.defaultview;         strfieldincludelist = new observablecollection<string>() { "include", "exclude" };         comboboxcolumn.itemssource = strfieldincludelist;     } 


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -