请帮我链接两个DataGridViews。我有两个DataGridViews来显示xml文件。 我把数据分成了两个表" " BasicData"和#34; Unbound" DataGridView1显示BasicData,而DataGridView2显示链接" Unbound"对于每个" BasicData"表格显示在上面的DataGridView。
我尝试过像这样的链接:
BasicData_BindingSource1.DataSource = dataset_DS1.Tables("set")
BasicData_BindingSource1.DataMember = "BasicData"
Unbound_BindingSource2.DataSource = BasicData_BindingSource1
Unbound_BindingSource2.DataMember = "Unbound"
DataGridView1.DataSource = BasicData_BindingSource1
DataGridView2.DataSource = Unbound_BindingSource2
此致
我的xml文件是这样的:
<?xml version="1.0" standalone="yes"?>
<main xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<set Attr1="Attr1Value" Attr2="Attr2Value">
<BasicData>
<Elem1>1.00</Elem1>
<Elem2>3500.00</Elem2>
<Elem3>90.00</Elem3>
<Elem4>90.00</Elem4>
<Elem5>7140.00</Elem5>
<Elem6>25.70</Elem6>
<Elem7>300.00</Elem7>
<Elem8>2.40</Elem8>
<Elem9>0.70</Elem9>
<Elem10>0.83</Elem10>
<Elem11>0.012</Elem11>
<Elem12>0.15</Elem12>
</BasicData>
<Unbound>
<DL_FT> 10280.00 </DL_FT>
<HL_FT> 2000 </HL_FT>
<DL_FT> 9600.00 </DL_FT>
<HL_FT> 1950 </HL_FT>
<DL_FT> 8280.00 </DL_FT>
<HL_FT> 1900 </HL_FT>
<DL_FT> 7500.00 </DL_FT>
<HL_FT> 1800 </HL_FT>
<DL_FT> 6280.00 </DL_FT>
<HL_FT> 1600 </HL_FT>
<DL_FT> 5300.00 </DL_FT>
<HL_FT> 1200 </HL_FT>
<DL_FT> 1280.00 </DL_FT>
<HL_FT> 1270 </HL_FT>
<DL_FT> 200.00 </DL_FT>
<HL_FT> 199 </HL_FT>
</Unbound>
</set>
<set Attr1="Attr1Value" Attr2="Attr2Value">
<BasicData>
<Elem1>12.00</Elem1>
<Elem2>2999.00</Elem2>
<Elem3>90.00</Elem3>
<Elem4>90.00</Elem4>
<Elem5>50.00</Elem5>
<Elem6>1000.00</Elem6>
<Elem7>123.00</Elem7>
<Elem8>0.123</Elem8>
<Elem9>0.7</Elem9>
<Elem10>0.83</Elem10>
<Elem11>0.012</Elem11>
<Elem12>0.15</Elem12>
</BasicData>
<Unbound>
<DL_FT>9999</DL_FT>
<HL_FT>+900</HL_FT>
<DL_FT>8999</DL_FT>
<HL_FT>800</HL_FT>
<DL_FT>7999</DL_FT>
<HL_FT>700</HL_FT>
<DL_FT>6999</DL_FT>
<HL_FT>600</HL_FT>
<DL_FT>5999</DL_FT>
<HL_FT>500</HL_FT>
</Unbound>
</set>
</main>
答案 0 :(得分:-1)
尝试按照xml查看是否有效
<?xml version="1.0" standalone="yes"?>
<set>
<BasicData>
<Elem1>1.00</Elem1>
<Elem2>3500.00</Elem2>
<Elem3>90.00</Elem3>
<Elem4>90.00</Elem4>
<Elem5>7140.00</Elem5>
<Elem6>25.70</Elem6>
<Elem7>300.00</Elem7>
<Elem8>2.40</Elem8>
<Elem9>0.70</Elem9>
<Elem10>0.83</Elem10>
<Elem11>0.012</Elem11>
<Elem12>0.15</Elem12>
</BasicData>
<Unbound>
<DL_FT> 10280.00 </DL_FT>
<HL_FT> 2000 </HL_FT>
<DL_FT> 9600.00 </DL_FT>
<HL_FT> 1950 </HL_FT>
<DL_FT> 8280.00 </DL_FT>
<HL_FT> 1900 </HL_FT>
<DL_FT> 7500.00 </DL_FT>
<HL_FT> 1800 </HL_FT>
<DL_FT> 6280.00 </DL_FT>
<HL_FT> 1600 </HL_FT>
<DL_FT> 5300.00 </DL_FT>
<HL_FT> 1200 </HL_FT>
<DL_FT> 1280.00 </DL_FT>
<HL_FT> 1270 </HL_FT>
<DL_FT> 200.00 </DL_FT>
<HL_FT> 199 </HL_FT>
</Unbound>
</set>