如何在Silverlight中使用键盘在ComboBox中选择文本 [英] How to select text in ComboBox using keyboard in silverlight

查看:65
本文介绍了如何在Silverlight中使用键盘在ComboBox中选择文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想如何在按下键盘按钮时在Silverlight中选择ComboBox中的文本。

请给出解决方案。

I want How to select text in ComboBox in silverlight when keyboard button pressd.
Please give solution.

推荐答案

private void comboBox_KeyDown(object sender, KeyEventArgs e)
        {
            if ((Keyboard.Modifiers & ModifierKeys.Control) > 0 && e.Key == Key.C)
            {
                Clipboard.SetText(this.comboBox1.SelectionBoxItem.ToString());
            }
        }



如果组合框处于活动状态,然后按ctrl + C,它的内容将被复制到剪贴板。我不知道这是不是你想要的。如果使用数据绑定,您可能希望使用SelectedValue属性,或将SelectedItem转换为您的类型,然后获取所需的文本。


If the combo box is active, and then you press ctrl+C, it's content will be copied to clipboard. I down't know if this is what you want. If you use data binding, you may want to use SelectedValue property, or convert SelectedItem to your type, and then get the text you want.


这篇关于如何在Silverlight中使用键盘在ComboBox中选择文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆