| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1119 人关注过本帖
标题:Devexpress LookUpEdit控件, 使用List类(自定义Class,多字段列),无法绑定 ...
只看楼主 加入收藏
xinrenq
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-3-15
收藏
 问题点数:0 回复次数:1 
Devexpress LookUpEdit控件, 使用List类(自定义Class,多字段列),无法绑定列(有记录行,但都为空白行)
描述如下:
1.Devexpress LookUpEdit控件,使用List类用于数据列表信息绑定,使用自定义Class,多字段列代码如下:
  Public Class UserArrayList
        Private VAL000 As Long
        Private VAL001 As String
        Private VAL002 As String

        Sub New(Optional xV000 As Long = 0, Optional xV001 As String = "", Optional xV002 As String = "" )
            Me.VAL000 = xV000
            Me.VAL001 = xV001
            Me.VAL002 = xV002  
        End Sub
    End Class

2.窗体中有Devexpress LookUpEdit控件,数据加载代码如下:
    Private Sub But_A04_Click(sender As Object, e As EventArgs) Handles But_A04.Click   
       Dim xList As New List(Of UserArrayList)
        xList.Add(New UserArrayList(1, "王一", "男"))
        xList.Add(New UserArrayList(2, "李二", "女"))
        xList.Add(New UserArrayList(3, "张三", "男"))
        xList.Add(New UserArrayList(4, "赵四", "女"))

         LookUpEdit1.Properties.DataSource = xList
          LookUpEdit1.Properties.NullText = ""
          LookUpEdit1.Properties.DisplayMember = "VAL001"
          LookUpEdit1.Properties.ValueMember = "VAL000"

        Dim xLookupCol As DevExpress.XtraEditors.Controls.LookUpColumnInfo
        xLookupCol= New DevExpress.XtraEditors.Controls.LookUpColumnInfo
        xLookupCol.FieldName = "VAL000"
        xLookupCol.Caption = "ID"
        LookUpEdit1.Properties.Columns.Add(xLookupCol)
        
        xLookupCol= New DevExpress.XtraEditors.Controls.LookUpColumnInfo
        xLookupCol.FieldName = "VAL001"
        xLookupCol.Caption = "姓名"
        LookUpEdit1.Properties.Columns.Add(xLookupCol)

        xLookupCol= New DevExpress.XtraEditors.Controls.LookUpColumnInfo
        xLookupCol.FieldName = "VAL002"
        xLookupCol.Caption = "性别"
        LookUpEdit1.Properties.Columns.Add(xLookupCol)
     End Sub
  
  3.以上运行结果:【LookUpEdit1】列表中,显示4行记录,但是3列全为空白,应当未绑定成功列字段

   求助,不知道哪出了问题!谢谢!      


 
搜索更多相关主题的帖子: Class 绑定 New 控件 Add 
2022-04-16 00:38
xinrenq
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-3-15
收藏
得分:0 
问题自我解决:
 Public Class UserArrayList
        Public Property VAL000 As Long
         Public Property VAL001 As String
         Public Property VAL002 As String
 
    End Class

'------重点,需要改成声明属性:Public Property
就可以了

[此贴子已经被作者于2022-4-28 00:04编辑过]

2022-04-28 00:02
快速回复:Devexpress LookUpEdit控件, 使用List类(自定义Class,多字段列),无法 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026009 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved