XML : dynamically create columns, rows in datagrid from XML metadeta using Deserialization in C#

I want to display XML metadata to data grid. Here grid columns will be dynamic and each cell can he different control on it. e.g one cell can contain dropdown another cell can contain checkbox. I have created classes from XML schema using "Paste XML As Classes" in VS and did the serialization to get all data from XML.

Here is the sample XML:

  <?xml version="1.0" encoding="utf-8"?>  <tabcontrol id="399" y="140" x="40" width="800" height="400">   <datagrid>    <grid id="101" name="Accessory" seqnr="100" iconid="982">       <column_definitions>          <column id="1" description="xx" name="xxxxxxxx" width="150" />          <column id="2" description="xxx" name="xxxxxxx" width="150" />          <column id="3" description="xxxx" name="xxxxxx" width="100"  />          <column id="4" description="xxxxx" name="xxxxx" width="120" />          <column id="5" description="xxxxxx" name="xxxx" width="120" />          <column id="6" description="xxxxxxx" name="xxx" width="100" />          <column id="7" description="xxxxxxxx" name="xx" width="300" />       </column_definitions>       <row_list>          <row id="201" height="22">             <cell columnid="1" datatype="string" type="TextBox">TeHere</cell>             <cell columnid="2" datatype="ztstring" type="ComboBox">                <combobox selected_key="..." sort_order="Ascending">                   <combobox_itemlist>                      <combobox_item key="...">...</combobox_item>                      <combobox_item key="10" >Option 10</combobox_item>                      <combobox_i key="20">Option 20</combobox_item>                   </combobox_itemlist>                </combobox>             </cell>             <cell columnid="3" type="TextBox" />             <cell columnid="4" datatype="ztstring" type="TextBox" />             <cell columnid="5" datatype="ztstring" type="TextBox" />             <cell columnid="6" datatype="ztstring" type="TextBox" />             <cell columnid="7" type="CheckBox"                       subtype="TwoState"                       datatype="ztbool">true</cell>            </row>          </row_list>       </grid>     </datagrid>  </tabcontrol>    

No comments:

Post a Comment