Jul
25
2009

My XtraLookupEdit, allows you to bind a DisplayValue and EditValue

User Rating: / 0
PoorBest 

The title might not seem to make sense so I will hopefully describe it better here.

I have a scenario where in my application the User has security restrictions, these restrictions include limiting the list of users they can assign to a record.

This is where the normal LookupEdit has it’s limitations, you can bind the EditValue but if the Lookup list doesn’t contain a record that is currently assigned it gives a blank/null display.

I was going to put a Suggestion/Question in over at the Support Center but I figured I should see what I could do first.

So I created a simple inherited LookupEdit control, I then added my DisplayValue property which would hold the value I want displayed regardless of the EditValue, next was easy to accomplish by just handling the CustomDisplayText event and violla, I bind the ID to the EditValue and the Display property to the DisplayValue.

Public Class XtraLookupEdit
    Inherits DevExpress.XtraEditors.LookUpEdit
 
    Private _displayValue As String
    <System.ComponentModel.Bindable(True)> _
    Public Property DisplayValue() As String
        Get
            Return _displayValue
        End Get
        Set(ByVal Value As String)
            _displayValue = Value
        End Set
    End Property
 
    Public Sub DisplayText(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs) Handles Me.CustomDisplayText
        e.DisplayText = DisplayValue
    End Sub
End Class

When I get some more time I will ellaborate more in how this is used however if you have any questions in the mean time don’t hesitate to ask.

Add comment

Although I believe your free to say what you want, please don't abuse either myself or other peoples, be constructive.


Security code
Refresh

Should AussieALF stay bald?




Results

Latest Comments

My Twitter

Follow me on twitter