Differences between selectedtext, selecteditem, and text attributes of ComboBox

Source: Internet
Author: User
ComboBox. selectedtext attribute
Syntax
C #
Public String selectedtext {Get; set ;}
Attribute Value
Indicates the string of the currently selected text in the combo box. If Dropdownstyle Set Dropdownlist The return value is a null string ("").
ComboBox. selecteditem attribute
Syntax
C #
[Bindableattribute (true)]
Public object selecteditem {Get; set ;}
The property value is the object of the currently selected item. If no item is selected, it is a null reference (nothing in Visual Basic ).
Remarks When Selecteditem When the attribute is set to an object, ComboBox Try to make this object the currently selected object in the list. If this object is found in the list, it is displayed in ComboBox And Selectedindex Set the attribute to the corresponding index. If the object does not exist in the list Selectedindex Property retains its current value.
ComboBox. Text attributes
Gets or sets the text associated with the control.
Syntax
C #
[Bindableattribute (true)]
[Localizableattribute (true)]
Public override string text {Get; set ;}
The text associated with the property value and the control.
Remarks
When set Text When the attribute is null, the null reference (nothing in Visual Basic) or the Null String ("") will Selectedindex Set to-1.

Therefore, in the drop-down ComboBox, you can only use cbx. text or cbx. selecteditem. tostring () to obtain the value of ComboBox.

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.