首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XtraLabel DataBinding

XtraLabel DataBinding
EN

Stack Overflow用户
提问于 2010-08-29 23:22:10
回答 1查看 1.1K关注 0票数 1

我使用XtraRepo

代码语言:javascript
复制
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();

在报告中,我只有第一条记录。我怎么能写出所有的记录。谢谢!}

EN

回答 1

Stack Overflow用户

发布于 2010-08-29 23:56:48

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

代码语言:javascript
复制
r.DataSource = catList;

另请参阅How to: Bind a Report to a Collection of Custom Objects

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3595312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档