组合框背景颜色更改 [英] combobox background colour change
本文介绍了组合框背景颜色更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题:
我有一种形式,很少有组合框.我想更改其值由用户更改的那些组合框的背景颜色.这样用户就可以知道自己修改了哪个组合框值.
我在Visual Studio 2010中使用wpf.
Question :
i am having one form on which there are few comboboxes. I want to change background colour of those combobox whose value is changed by user. so that user would be able to make sense which combobox value he has modified.
i am using wpf in visual studio 2010
推荐答案
那是什么问题?在组合框发生更改事件时,只需在该控件上添加边框或更改回颜色即可.
您只需在这里处理组合框SelectionChange
事件: Selector.SelectionChanged事件 [ ^ ]
So what''s the issue? On change event of the combobox, just put a border on that control or change back color.
ComboboxSelectionChange
event is all you need to handle, here: Selector.SelectionChanged Event[^]
问题出在哪里?
C#:
And what''s the problem?
C#:
MyComboBox.SelectionChanged += (sender, eventArgs) => {
((ComboBox)sender).Background =
CalculateColor(((ComboBox)sender).SelectedValue); //whatever it is
}; //MyComboBox.SelectionChanged
这篇关于组合框背景颜色更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文