开发者

ComboBox's Selected Value Changed On Lost Focus in VB.NET

开发者 https://www.devze.com 2022-12-08 21:27 出处:网络
I have a datagridview(dgv) with a DataGridViewComboBoxColumn(colLocation) colLocation.AutoComplete = False

I have a datagridview(dgv) with a DataGridViewComboBoxColumn(colLocation)

colLocation.AutoComplete = False
colLocation.HeaderText = "Stored to"
colLocation.DataSource = DB.getLocation()
colLocation.DisplayMember = "description"
colLocation.ValueMember = "id"

I added the colLocation to dgv.

"descirption" contains Unico开发者_运维百科de characters. I can see the comboBox correctly and choose the item.

The problem is when the comboBox lost the focus, the value is changed to first item of the comboBox.

Any suggestion?

Updated:

I found out that the ComboBox doesn't change the data when the DisplayMember is in English characters.

It changes only when the DisplayMember is in Unicode chracter. Any idea for how could solve this? – tunwn 0 secs ago


Your .aspx page should have something like so:

<asp:DropDownList Width="90px" ID="ddlExpenseTypes" OnSelectedIndexChanged="ddlExpenseTypes_SelectedIndexChanged"  DataSource='<%# GetExpenseTypes() %>' SelectedValue='<%# Bind("ExpenseReasonID") %>' DataTextField="ExpenseReasonID" DataValueField="ExpenseReasonID" AutoPostBack="true"  runat="server" ></asp:DropDownList>

That is you need a functional call for index changed. A function call for filling the drop down ist (DataSource) and a function call to set the SelectedValue of the drop down list.


Is this DataGridView databound? You haven't specified a value for DataPropertyName, so there's nothing for colLocation.ValueMember's ID selection to bind to.

0

精彩评论

暂无评论...
验证码 换一张
取 消