c# - how to load a datagridview with my data from xml -
i have xml:
<container_1 attr1="..." attr2="..." attr3="..."> <rekord_1> <type_1 attr1="..." attr2="..." ... /> <type_2 attr1="..." attr2="..." ... /> </rekord_1> <rekord_2>... </rekord_2> . . <rekord_n> ... </rekord_n> </container_1>
i can parse way want , show in console app (using xmlelements
, xmlnodelists
, few loops) want make app gui , table view. form app read xml, can handle 1 tag right now. example, if container_1
tag, outputs container_1
's attributes itself, want show records under container_1
in table view also.
i want make view-able older program in console.
how can out data xml able work elements/attributes? because want set place in table view. documentation should read? or there example useful me?
edited(aug. 20): here main part of code:
private void button1_click(object sender, eventargs e) { stream input=null; openfiledialog dialog = new openfiledialog(); openfiledialog1.initialdirectory = "c:/"; openfiledialog1.filter = "xml file | *.xml"; openfiledialog1.filterindex = 2; openfiledialog1.restoredirectory = true; if (openfiledialog1.showdialog() == dialogresult.ok) { try { if ((input = openfiledialog1.openfile()) != null) { using (input) { xmlreader xmlfile = xmlreader.create(input, new xmlreadersettings()); dataset dataset = new dataset(); dataset.readxml(xmlfile); dataset containers = new dataset(); datagridview1.datasource = dataset.tables[tag]; xmlfile.close(); } } } catch (exception ex) { messagebox.show("error"); } } }
this function display if tag container or rekord , makes output: outputs
but can't display container1+ rekords,container2+its rekords , on,only containers or rekords in same time.
sounds want pull xml dataset , feed dataset gridview.
and looks has asked question on stack exchange well
any way populate items xml datagridview using c#
addition
what have dataset
multiple datatables
. datagridview
able display 1 datatable
@ time.
when code
datagridview1.datasource = dataset.tables[tag];
and put container_1
in tag
pulling container_1
table of dataset.
i suggesting @ msdn datagridview, dataset, , datatable see if going work you.
maybe check out c# datagridview tutorial
it couldn't hurt.
Comments
Post a Comment