edykay
edykay

Reputation: 1

How to show default value in control grid in a repositoryitemlookupedit column?

I linked a datasource table to the control grid:

enter image description here

and all the data from the table are shown successfuly exept the "Type" column that I assigned to a "RepositoryItemLookupEdit" to choose the types from a list. As seen in the screenshot, the displayed member and the value member properties are set correctly. After selecting a type from the RepositoryItemLookupEdit, the selected one remains shown on the grid (when selecting another cell). So my problem is that I want to display the initial values in the "Type" column.

Upvotes: 0

Views: 1635

Answers (2)

ayman mohammed
ayman mohammed

Reputation: 1

From ColumnEdit select DisplayMember select your field

[First][1]: https://i.sstatic.net/LoVZO.png

[Second][2]: https://i.sstatic.net/DLMdW.png

Upvotes: 0

Chris
Chris

Reputation: 5615

You need to handle the CustomDisplayText of the RepositoryItem

If your 'Type' column is bound to a dataobject such as...

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

You need to populate the DisplayText of the cell with the value of the cell.

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

Upvotes: 0

Related Questions