none
XML, treeview and Propertygrid RRS feed

  • Question

  • I have a configuration xml like,

    <Analyzer Name="aaa" Class="aaa" SubClass="sss" AcquisitionMode="Master">

       

      <Configuration>

       <Parameter Name="AnalyzerModel"   DataType="String"      AccessLevel="r" InitialValue="FBRM"/>

       <Parameter1 Name="VendorName…………..

       <Parameter2 Name="SerialNumber”…………………….

       <Parameter3 Name="aaa”…………………….

     

     </Configuration>

       

    <Status>

       

    <Parameter Name="AnalyzerStatus" DataType="Integer" AccessLevel="r"  InitialValue="1" ValueRank="-1">

            <Constraint Type="Enum">

              <Enum Name="NORMAL" Value="1" />

              <Enum Name="MAINTENANCE_REQUIRED" Value="2" />

              <Enum Name="FAULT" Value="3" />

            </Constraint>

          </Parameter>

    </Status>

    <FactorySettings></FactorySettings>

    <Accessories></Accessories>

    <CustomCommands></CustomCommands>

    <Channels>

          <Channel Name="Channel1">

            <Configuration>

    :

    :

    :

     

    My Form has a split container, with 2 panels. Left side treeview and propertygrid on the righthand side.

    Treeview is loaded dynamically from XML and have the following structure,

     

    Analyzer

       -  Configuraton

       -  Status

       -  Factorysettings

       -  Accessories

       -  CustomCommands

       -  Channels

              -  Configuraton

              -  Status

              -  Factorysettings

              -  Accessories

              -  CustomCommands

              -  Channels

    Whenever I click on configuration node all the 4 parameters of the configuration would be displayed on the propertygrid.

    Likewise Status has Type=Enum which should be dynamically be displayed in the combobox.

    I have the following code to do this,

     

    I am creating dynamic combobox by implementing StringConverter,

     

     

    Now the problem is,

     

    1.  Combobox displays System.string[] by default. I want empty combobox.

    2.  When I select something from combox, next if I try to select some item from the same combobox it displays empty. StandardValuesCollection(c) is becoming null;

    3.  How do I serialize from propertygrid to XML file. because here when I change something in the propertygrid, xml file shuld be updated with the new values.

    That means my input and output xml should be same with the format.

     

     

    Monday, July 4, 2011 10:07 AM

Answers