无法取消选择我的 DevExpress LookUpEdit
我有一个 DevExpress LookUpEdit,正在 VB.Net 中的 Visual Studio 2008 中使用。
我将 LookUpEdit 绑定到我的数据源,它显示的值可能为空或数据源中的行之一。我的程序显示一个树列表,当选择一个节点时,LookUpEdit 应该显示分配的值(可能为空)并让用户重新分配该值。 我确实将 LookUpEdit.Properties.AllowNullInput 设置为 True。 现在,当程序首次启动时,如果我选择的树列表中的第一个节点具有空值,如果我更改该值,LookUpEdit 将不显示任何内容LookUpEdit 的值在数据库中发生变化,如果我更改为具有 LookUpEdit 值的节点,该值会显示。
问题是,如果我从一个有值的节点切换到没有 LookUpEdit 的节点,则会显示前一个值。我已经通过了调试器,它仍然可以正确地进行获取。
我尝试重置 LookUpEdit.Text、LookUpEdit.EditValue 和 LookUpEdit.SelectedText,但没有任何效果。我什至复制了 LookUpEdit 第一次不显示任何内容时的条件(LookUpEdit.Text = "" 和 LookUpEdit.EditValue = " "),但它仍然显示最后一个值。
我正在设置实际值 lueLocation.EditValue = lueLocation.Properties.GetKeyValueByDisplayText(valueName)
编辑
所以我缩小了范围。在我将 Text 和 EditValue 设置为空之后,
lueLocation.Text = Nothing
lueLocation.EditValue = Nothing
值就被设置了。问题是在设置值的过程中会打开下拉菜单。所以我用lueLocation.ClosePopup()来关闭它。由于某种原因,当它被调用时,它会将 .Text
和 .EditValue
更改回以前的值,从而调用 TextChanged Event
。
不知道为什么,但我无法保持下拉菜单打开。
I have a DevExpress LookUpEdit that I am using withing Visual Studio 2008 in VB.Net.
I have the LookUpEdit bound to my datasource and the value that it is displaying may be null or one of the rows in the datasource. My program displays a treelist and when a node is select the LookUpEdit is supposed to display the assigned value (could be null) and let the user reassign the value. I do have the LookUpEdit.Properties.AllowNullInput set to True. Right now when the program first starts if the first node in the treelist I choose has a null value the LookUpEdit displays nothing, if I change the value of the LookUpEdit the value changes in the database, if I change to a node that has a value for the LookUpEdit the value does display.
The problem is that if I switch from a node with a value to one without the LookUpEdit displays the previous value. I have gone through the debugger and it is still going through the fetch properly.
I have tried to reset the LookUpEdit.Text, LookUpEdit.EditValue and LookUpEdit.SelectedText but nothing works. I even replicated the conditions that the LookUpEdit has when it first displays nothing (LookUpEdit.Text = "" and LookUpEdit.EditValue = " ") but it still displays the last value.
I am setting the actual value with lueLocation.EditValue = lueLocation.Properties.GetKeyValueByDisplayText(valueName)
EDIT
So I narrowed it down. After I set the Text and EditValue to nothing
lueLocation.Text = Nothing
lueLocation.EditValue = Nothing
The values are set. The problem is that in the act of setting the value the dropdown menu opens. So I get it to close with lueLocation.ClosePopup()
. For some reason when it gets called it changes the .Text
and .EditValue
back to the previous values and thus calls the TextChanged Event
.
No clue why but I can't keep the dropdown menu open.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,在 UI 中,Ctrl-Del 组合键应将其清除并将其设置为空。否则,在代码中,您应该能够设置 EditValue = Nothing 就可以了。
以下是 DX 网站上的几个链接:
搜索:http://search.devexpress.com/?q=clear+lookupedit&p=T4%7cP1%7c4&d=447
http://www.devexpress.com/Support/Center/p/Q96464.aspx
http://www.devexpress.com/Support/Center/p/Q270901.aspx
Generally in the UI the key combination of Ctrl-Del should clear it and set it to nothing. Otherwise in code, you should be able to set the EditValue = Nothing and that should do it.
Here are a couple of links on the DX site:
Search: http://search.devexpress.com/?q=clear+lookupedit&p=T4%7cP1%7c4&d=447
http://www.devexpress.com/Support/Center/p/Q96464.aspx
http://www.devexpress.com/Support/Center/p/Q270901.aspx
我解决了这个问题。正如您在编辑中看到的,实际上是
lueLocation.ClosePopup()
导致它恢复到之前的.Text
和.EditValue
> 价值观。我删除了lueLocation.ClosePopup()
,这导致我的界面在值为 null 时下拉菜单保持打开状态,如果存在实际分配的值则下拉菜单关闭。我发现如果我将
.EditValue
设置为DBNull.Value
(lueLocation.EditValue = DBNull.Value
) 而不是Nothing< /code>、
""
或" "
它将分配给 LookUpEdit 的值设置为空,并自动关闭下拉菜单。I solved the problem. As you can see in the Edit it was the
lueLocation.ClosePopup()
that actually caused it to revert back to the previous.Text
and.EditValue
values. I removed thelueLocation.ClosePopup()
which then caused my interface to have the dropdowns remain open if the value was null and closed if there was an actual assigned value.I found that if I set the
.EditValue
toDBNull.Value
(lueLocation.EditValue = DBNull.Value
) rather thanNothing
,""
, or" "
it set the value assigned to the LookUpEdit to nothing and automatically closed the dropdown menu.