Solved

Help with disabling displaying field in combobox if exist in an xml file

Posted on 2016-08-08
6
40 Views
Last Modified: 2016-08-09
Hi,

I'm using the code below to display data from a DataGrid in a combobox:

 ComboBox2.DataSource = (From col As C1.Win.C1TrueDBGrid.C1DataColumn In C1Data.Columns Select col.Caption).ToList()
       

How do I modify the code to display data in the combobox only if the field name in C1Data exist in an xmlmfile?

For example if Main.xml contains the following data elements (NSC,FIF,AGD,UVN) in C1Data contains the following columns((NSC,FIF,NAS, PCS,NMN) I want the dropdown list to only contain (NSC,FIF)

Thanks,

Victor
0
Comment
Question by:vcharles
  • 3
  • 3
6 Comments
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 41748730
Hi Victor;

And what does the schema/structure  of the XML look like?
0
 

Author Comment

by:vcharles
ID: 41748997
Hi Fernando,

The XML format file is in the following format:

<Root>
<Fields>
<NSC></NSC>
<FIF></FIF>
<AGD></AGD>
<UVN></UVN>
</Fields
</Root>

Thanks,

victor
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 41749069
Hi Victor;

This should do what you are looking for.
'' Holds the node names of the XML document
Dim xmlTagNames As List(Of String)
'' Load the XML document
Dim xdoc As XDocument = XDocument.Load("Main.xml")
'' Get the names of the nodes
xmlTagNames = (From n In xdoc.Root.Element("Fields").Descendants()
               Select n.Name.LocalName).ToList()
'' Filter out the needed columns.
ComboBox2.DataSource = (From col As C1.Win.C1TrueDBGrid.C1DataColumn In C1Data.Columns
                        Where xmlTagNames.Contains(col.Caption)
                        Select col.Caption).ToList()

Open in new window

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:vcharles
ID: 41749755
Hi Fernando,

It works. Thank You.

Is it possible to modify the code using multiple xml files? For example I want to load the combobox with values in the Grid matching fields in both Main.xml and Sub.xml. Other option is to create one xml file from Main and Sub.xml and use the existing code.

If necessary I can open a new issue.

Victor
0
 

Author Closing Comment

by:vcharles
ID: 41749758
Please see my last comments.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 41749761
Hi Victory;

I believe you would be better off using one XML file because you will then need to read in two or more XML files then query both and then combine the results into one list.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now