General Usage of lookupedit

Source: Internet
Author: User

 

Bind Data source:

Lookupedit. properties. valuemember = actually used field; // equivalent to editvalue

Lookupedit. properties. displaymember = field to be displayed; // equivalent to text

Lookupedit. properties. datasource = data source;

Determine whether to select the drop-down list:

If (this. lookupedit. editvalue = null | this. lookupedit. editvalue. tostring () = "nulltext ")

{

// The prompt message indicating that no drop-down box is selected

}

Clear nulltext value:

Lookupedit. properties. nulltext = null;

Set the nulltext value:

Lookupedit. properties. nulltext = "Please select ";

Use the value of lookupedit1:

Variable = this. lookupedit. editvalue. tostring () // is the value of ookupedit. properties. valuemember

Variable = this. lookupedit. text. trim () // The value of ookupedit. properties. displaymember

It is particularly worth noting that sometimes we need to use lookupedit to achieve some of the effects of combox. during actual use, the first item will be selected by default when the program is loaded. Its settings are as follows:

Lookupedit. itemindex = 0; // select the first item

Lookupedit. itemindex =-1; // no option. In this case, the nulltext value is displayed. In fact, as long as editvalue = null, lookupedit displays nulltext.

Lookupedit1.editvalue = value; // automatically searches for datasouse and selects the matched value. If no value exists, the value is null. The value must be of the same data type as valuemember.

However, when you select a record for lookupedit, bindingsourse. the value of current is always the first record. To obtain the record of your data source, you must use lookupedit. getdatasoursebykeyvalue (keyvalue) and (object) are forcibly transferred. However, you must note that the keyvalue must be the primary key of your data source. Otherwise, you obtain the first record with the same key. What if multiple key values determine a record?

Dev express also has a corresponding solution, that is, using gridlookupedit, which should be a combination of gridview and lookupedit. You can use this to select records with the same primary key, use gridlookupeditview. getdatasourcerowindex (gridlookupeditview. focusedrowhandle.

If you do not want to display [EditValue is null] In the lookupedit box during running, set the EditValue attribute Type to the String Type. If the Value is empty, it is OK.

Similarly, for the lookupedit field in gridControl, you only need to set the NullText attribute to null.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.