1

这样我就可以从我的 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)));
    }
4

1 回答 1

1

进行以下更改:

((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)));

testDsrcConfigs.Add(
                     new SdrcConfig(
                         dr.Cells["bid"].Value.ToString(), 
                         dr.Cells["bdesc"].Value.ToString(),        
                         covTrafLane,
                         devPos, devnum,
                         ((MyConfig.
    .ObuTransactionSystemConfig as DsrcTransactionSystemConfig).
         DsrcSystemConfig as MultiLaneDsrcSystemConfig).DsrcConfigs[0].Settings);
于 2012-10-31T21:32:51.847 回答