XtraLabel 数据绑定

发布于 2024-09-16 13:54:57 字数 1232 浏览 4 评论 0原文

我在报告中使用 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();

我只有第一条记录。我怎样才能写出所有记录。 谢谢你! }

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

In report I have only first record. How can I write all records.
Thank you!
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猛虎独行 2024-09-23 13:54:57

您应该将数据 (catList) 绑定到 Report.DataSource。

r.DataSource = catList;

另请参阅如何:将报表绑定到自定义对象集合

You should bind data (catList) to Report.DataSource.

r.DataSource = catList;

see also How to: Bind a Report to a Collection of Custom Objects

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文