Skip to content

DevExpress-Examples/winforms-lookup-display-custom-text-for-not-found-edit-value

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Lookup - Display custom text if the lookup's value is not found in the drop-down list

This example handles the Properties.CustomDisplayText event to display custom text if the lookup's EditValue does not match any value in the drop-down list (the value does not exist in the data source).

const string NotFoundText = "???";

private void RepositoryItemLookUpEdit_CustomDisplayText(object sender, CustomDisplayTextEventArgs e) {
    RepositoryItemLookUpEdit props;
    if(sender is LookUpEdit)
        props = (sender as LookUpEdit).Properties;
    else
        props = sender as RepositoryItemLookUpEdit;
    
    if(props != null && (e.Value is int)) {
        object row = props.GetDataSourceRowByKeyValue(e.Value);
        if(row == null) {
            e.DisplayText = NotFoundText;
        }
    }
}

Files to Review

Documentation

See Also

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Display custom text if the lookup's value is not found in the dropdown list.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 5