Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6829139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:27:53+00:00 2026-05-26T22:27:53+00:00

Getting frustrated looking for answers for hours on this one… I have an .xml

  • 0

Getting frustrated looking for answers for hours on this one…

I have an .xml file that I deserialize into a DataSet, along with an .xsd so types of the dataset are known. Like this:

 mDataSetVariables = new DataSet();
 using (var rdr = new StringReader(Properties.Resources.VariableListSchema))
 {
     mDataSetVariables.ReadXmlSchema(rdr);
 }
 mDataSetVariables.ReadXml(filename, XmlReadMode.ReadSchema);

 dataGridView_Params.Columns.Clear();
 dataGridView_Params.DataSource = mDataSetVariables;
 dataGridView_Params.DataMember = "Variable";

The .xml file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<VariableList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <List>
    <Variable>
      <Name>kPeakPeriodAccThresh</Name>
      <Type>FixedPoint</Type>
      <Min>0.0001</Min>
      <Max>0.02</Max>
      <InitialValue>0.003</InitialValue>
      <BestValue>0.0052570276796268427</BestValue>
      <CurrentValue>0.006459431678617374</CurrentValue>
      <Enabled>true</Enabled>
    </Variable>
    < ... more variables here >

And the .xsd looks like this (generated by xsd.exe on my classes of type Variable and VariableList):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="VariableList" nillable="true" type="VariableList" />
  <xs:complexType name="VariableList">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="List" type="ArrayOfVariable" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ArrayOfVariable">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Variable" nillable="true" type="Variable" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Variable">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string" />
      <xs:element minOccurs="1" maxOccurs="1" name="Type" type="VariableType" />
      <xs:element minOccurs="1" maxOccurs="1" name="Min" type="xs:double" />
      <xs:element minOccurs="1" maxOccurs="1" name="Max" type="xs:double" />
      <xs:element minOccurs="1" maxOccurs="1" name="InitialValue" type="xs:double" />
      <xs:element minOccurs="1" maxOccurs="1" name="BestValue" type="xs:double" />
      <xs:element minOccurs="1" maxOccurs="1" name="CurrentValue" type="xs:double" />
      <xs:element minOccurs="1" maxOccurs="1" name="Enabled" type="xs:boolean" />
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="VariableType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Integer" />
      <xs:enumeration value="FixedPoint" />
      <xs:enumeration value="Boolean" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

When I bind the DataSet to the Datagridview, the Boolean value “Enabled” automatically gets represented with checkboxcolumn. How can I get the “Type” column to automatically be a comboboxcolumn with a dropdown of the enum types?

I’ve found several other answers online but none that seem to work with my scenario. If I have to change how things are arranged (i.e. use a strongly typed data set), then I guess I will but I’d like to get it working with the code as is.

Many thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:27:54+00:00Added an answer on May 26, 2026 at 10:27 pm

    the problem is, that as far as your dataset is concerned, that column is no enum but a string …

    the dataset will happily ignore that enum restriction …

    you can verify that, if you ask your mDataSetVariables for getXmlSchema()
    note the change from

    <xs:simpleType name="VariableType">
      <xs:restriction base="xs:string">
        <xs:enumeration value="Integer" />
        <xs:enumeration value="FixedPoint" />
        <xs:enumeration value="Boolean" />
    </xs:restriction>
    

    to

      <xs:simpleType name="VariableType">
        <xs:restriction base="xs:string" />
      </xs:simpleType>
    

    to handle this problem you will have to parse the xsd yourself, and identify the enum columns, build up string arrays with the appropriate values, and deliver those as datasource for the comboboxes …

    i would go for strongly typed datasets …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im getting frustrated because of OpenDNS and other services (ie: roadrunner) that now always
I use an sql server regularly and have recently been getting frustrated by the
So I am getting pretty frustrated with this and feel the only way to
I''m looking to get this correct and i'm getting a bit fustrated with this.
I'm getting pretty frustrated with this, and hope the community can help me out.
I am getting pretty frustrated, i have an tcp server running on my mac
Arghhh! I'm getting so frustrated trying to get my head around this WCF service.
I am really getting frustrated with Google Chrome... I have version 3.0.195.27 and want
Getting pretty frustrated with this. I installed pygtk 2.24, pycairo 1.8.10, and pyobject 2.28.3
I have an entity framework model, and I noticed that one table, a usergroup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.