如何在字符串参数中传递List <object>

时间:2019-05-17 08:06:50

标签: c# string parameter-passing listobject

我有一个采用字符串参数的方法。我必须在此字符串中传递Class2对象的列表。 Class2具有2个属性:int Day,float Hours。 函数是:

public void AddBoundLabel(string bindingMember, Rectangle bounds);

Classes2是Class2的列表;在运行时通过查询填充。 Class2具有两个属性:int Day,float Hours。

// I tried
 report.AddBoundLabel("[Classes2].[Hours]", new Rectangle(60, 20, 25, 20)); // this gives me the first element

 report.AddBoundLabel("[Classes2][0].[Hours]", new Rectangle(60, 20, 25, 20));// this gives me nothing


// the method
  public void AddBoundLabel(string bindingMember, Rectangle bounds)
        {
            // Create a label.
            XRLabel label = new XRLabel();

            // Add the label to the report's Detail band.
            Detail.Controls.Add(label);

            // Set its location and size.
            label.Location = bounds.Location;
            label.Size = bounds.Size;          


            // Specify the label's binding depending on the data binding mode.
            if (Settings.Default.UserDesignerOptions.DataBindingMode == DataBindingMode.Bindings)
                label.DataBindings.Add("Text", null, bindingMember);
            else label.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", bindingMember));            
        }

我想获取列表的所有值。 提前致谢, 尼科

0 个答案:

没有答案