Infragistics Ultragrid valueList/UltraDropDown
我需要处理什么事件才能允许用户在值列表或超级下拉列表中添加“水果”。
由于它是 KVP,我总是遇到格式异常
Dictionary<int,string> fruits = new Dictionary<int,string>();
private void FruitInit()
{
//Create some fruit
fruits.Add(-1,"apple");
fruits.Add(-2,"banana");
//Create and add to the ultraDropDown
UltraDropDown fruitUltraDropDown = new UltraDropDown();
fruitUltraDropDown.DataSource = fruits.ToList();
fruitUltraDropDown.DisplayMember = "Value";
fruitUltraDropDown.ValueMember = "Key";
MyUltraGrid.DisplayLayout.Bands[0].Columns["MyColumn"].ValueList = fruitUltraDropDown;
}
我可以处理什么事件,因此当用户输入“grape”时,我可以使用自己的密钥将其添加到字典中,并将其添加到下拉列表中。目前,如果我在单元格中输入“grape”,我只会收到格式异常。
问候
_Eric
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
收到 Mike@infragistics 的回复,我不知道 ValueListResolved
来自的回答迈克
Got a response from Mike@infragistics, I didn't know about ValueListResolved
Answer from Mike
如果您对值列表使用“UltraDropDown”,则可以处理它的“BeforeDropDown”事件。将网格中的“已使用”值与 UltraDropDown 中的值进行比较,然后隐藏正在使用的值。
为我工作。
If you use an "UltraDropDown" for the value list, you can handle it's "BeforeDropDown" event. Compare the "used" values in the grid to the values in the UltraDropDown, then hide the ones that are in use.
Worked for me.
这可能与您的问题相关,也可能不相关,但是您的代码中有很多奇怪的事情。
Infragistics 包括用于在 Designer.cs 文件中创建、填充和显示控件的向导。像这样实例化一个控件会丢弃所有设计器数据并创建一个新的默认控件。你真的有意这样做吗?这是 Designer.cs 文件的摘录吗?
这将从您的
Dictionary
中创建一个新的List>
。fruits
现在无法访问并且符合垃圾回收条件,对其所做的任何更改都不会传播到fruitUltraDropDown
。为什么你创造水果
只是为了扔掉它?在哪里键入?
fruitUltraDropDown
?设计器数据已被丢弃,因此fruitUltraDropDown
不可编辑,除非有大量代码未显示。MyUltraGrid
?您没有为此显示任何代码,因此没有人知道它实现了什么。文本字段?程序化数据?完全是个谜。向
Dictionary
添加任何内容都是毫无意义的,因为您不再使用它。如果您想将其添加到ultraDropDown1.DataSource
中,则必须添加一个KeyValuePair
:这只会将条目添加到后备存储中。如果您想将其包含在
ultraDropDown1
中:如果这没有帮助,您必须向您的问题添加足够的信息,以便没有您的源代码的人能够理解您正在尝试执行的操作。
This may or may not be relevant to your question, but there are many strange things in your code.
Infragistics includes wizards to create, populate, and display controls in the designer.cs file. Instantiating a control like this throws away all the designer data and creates a new, default control. Do you really intend this? Is this an excerpt from the designer.cs file?
This creates a new
List<KeyValuePair<int, string>>
from yourDictionary
.fruits
is now unreachable and eligible for garbage collection, any change made to it will never be propagated tofruitUltraDropDown
. Why are you creatingfruits
only to throw it away?Types where?
fruitUltraDropDown
? The designer data has been thrown away sofruitUltraDropDown
is not editable, unless there is a lot of code you are not showing.MyUltraGrid
? You do not show any code for this, so no one can have any idea what it implements. A text field? Programmatic data? A total mystery.Adding anything to
Dictionary
is pointless because you no longer use it. If you want to add it toultraDropDown1.DataSource
you have to add aKeyValuePair<int, string>
:This will just add the entry to the backing store. If you want to include it in
ultraDropDown1
:If this is not helpful you must add enough information to your question so that someone without your source code can understand what you are trying to do.