このようにして、datagridviewからリストとしてアクセスしています。私がここで直面している問題..私が6 rows
DGVにいる場合、それがリストに更新されると、それが表示されます36rows
。どうすればこの問題を解決できますか?
for (int i = 0; i < testDsrcConfigs .Count; i++ )
{
Console.WriteLine(testDsrcConfigs [i]);
}
forループから、6行が表示されます。使用できますfor loop
か?メンバーにアクセスするためにループをどのように適応させることができますか??助けてください..!
List<SdrcConfig> testDsrcConfigs = new List<SdrcConfig>();
foreach (GridViewRowInfo dr in RadGridView.Rows)
{
//Create a TrafficLane list
List<TrafficLane> covTrafLane = new List<TrafficLane>();
if (dr.Cells["bct0"].Value != "XXXX")
{
covTrafLane.Add(new TrafficLane(dr.Cells["bct0"].Value.ToString()));
}
if (dr.Cells["bct1"].Value != "XXXX")
{
covTrafLane.Add(new TrafficLane(dr.Cells["bct1"].Value.ToString()));
}
if (dr.Cells["bct2"].Value != "XXXX")
{
covTrafLane.Add(new TrafficLane(dr.Cells["bct2"].Value.ToString()));
}
if (dr.Cells["bct3"].Value != "XXXX")
{
covTrafLane.Add(new TrafficLane(dr.Cells["bct3"].Value.ToString()));
}
//Create RseDevicePosition
DevicePosition devPos;
int ctx;
Int32.TryParse(dr.Cells["bx"].Value.ToString(), out ctx);
int cty;
Int32.TryParse(dr.Cells["by"].Value.ToString(), out cty);
int ctz;
Int32.TryParse(dr.Cells["bz"].Value.ToString(), out ctz);
int bazu;
Int32.TryParse(dr.Cells["bazim"].Value.ToString(), out bazu);
int bele;
Int32.TryParse(dr.Cells["belev"].Value.ToString(), out bele);
int bti;
Int32.TryParse(dr.Cells["btilt"].Value.ToString(), out bti);
ushort devnum = UInt16.Parse(dr.Cells["bdevnum"].Value.ToString());
devPos = new DevicePosition(
new ValueWithUnit<int>(ctx, "mm"),
new ValueWithUnit<int>(cty, "mm"),
new ValueWithUnit<int>(ctz, "mm"),
new ValueWithUnit<int>(bazu, "tenthOfDegree"),
new ValueWithUnit<int>(bele, "tenthOfDegree"),
new ValueWithUnit<int>(bti, "tenthOfDegree"));
((MyConfig.
.ObuTransactionSystemConfig as DsrcTransactionSystemConfig).
DsrcSystemConfig as MultiLaneDsrcSystemConfig).DsrcConfigs.ForEach(
dsrcBeacon => testDsrcConfigs.Add(
new SdrcConfig(
dr.Cells["bid"].Value.ToString(),
dr.Cells["bdesc"].Value.ToString(),
covTrafLane,
devPos, devnum,
dsrcBeacon.Settings)));
}