XtraLabel DataBinding - PullRequest
       2

XtraLabel DataBinding

1 голос
/ 29 августа 2010

Я использую XtraRepo

rt to creating report. I add two labels in designer with names: lblCategoryName and lblCategoryDescription. 

Data binding and show preview:

   public class Category
    {
        public string CategoryName { get; set; }
        public string CategoryDesciption { get; set; }
        public Category(string name, string description)
        {
            CategoryName = name;
            CategoryDesciption = description;
        }
    }
 private void button1_Click(object sender, EventArgs e)
        {
            List<Category> catList = new List<Category>();
            catList.Add(new Category("one", "one desc"));
            catList.Add(new Category("two", "two desc"));
            catList.Add(new Category("three", "three desc"));
            XtraReport1 r = new XtraReport1();
            XRBinding binding = new XRBinding("Text", catList, "CategoryName", "Category: {0}");
            r.lblCatName.DataBindings.Add(binding);
            binding = new XRBinding("Text", catList, "CategoryDesciption", "Description: {0}");
            r.lblCatDescription.DataBindings.Add(binding);
            r.ShowPreview();

В отчете у меня есть только первая запись.Как я могу написать все записи.Спасибо!}

1 Ответ

0 голосов
/ 29 августа 2010

Вы должны привязать данные (catList) к Report.DataSource.

r.DataSource = catList;

см. Также Как: привязать отчет к коллекции пользовательских объектов

...