【问题标题】:How to show default value in control grid in a repositoryitemlookupedit column?如何在 repositoryitemlookupedit 列的控制网格中显示默认值?
【发布时间】:2014-09-26 22:40:57
【问题描述】:

我将一个数据源表链接到控制网格:

并且表中的所有数据都成功显示,除了我分配给“RepositoryItemLookupEdit”以从列表中选择类型的“类型”列。如屏幕截图所示,显示的成员和值成员属性设置正确。从repositoryItemlookupEdit选择类型之后,所选的一个保持在网格上显示(选择另一个小区时)。所以我的问题是我想在“类型”列中显示初始值。

【问题讨论】:

  • 您可以将表中的值设置为默认值,您也可以对数据进行查询(取决于您的来源。如果您只是想直观地显示某些内容而无需要更改数据,您可以使用“Null Text”属性在未设置任何内容时显示某些内容。然后您必须假设 null 是其他地方的默认值。

标签: vb.net devexpress gridcontrol repositorylookupedit


【解决方案1】:

你需要处理RepositoryItem的CustomDisplayText

如果您的“类型”列绑定到数据对象,例如...

public class SomeType
    public property Name as string
    public property Description as string   
    public property Code as string  
End Class

您需要用单元格的值填充单元格的DisplayText

Private Sub RepositoryItem_CustomDisplayText(sender As Object, e As DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs) Handles RepositoryItemLookUpEdit1.CustomDisplayText
    Try
        Dim currentSomeType = TryCast(e.Value, SomeType)
        If Not currentSomeType Is Nothing Then
            'find the correct SomeType
            Dim currentSomeTypeName As String = currentSomeType.Name
            e.DisplayText = currentSomeTypeName
        End If
    Catch exception As Exception
    End Try
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多