如何在组合框中禁用高亮显示选定的项目C# [英] How to disable highlighting of a selected item in combobox uisng C#

查看:87
本文介绍了如何在组合框中禁用高亮显示选定的项目C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合框。

当我选择任何选项时,该选项不应突出显示。



如何使用C#

I am having a combobox.
When I select any option the option should not be highlighted.

How to do this using C#

推荐答案

最简单的方法是将焦点从组合框传递到另一个控件。例如,您可以将以下代码放在组合框选择更改事件中,假设您有另一个组合框:

The simplest method to use is to pass the focus from your combobox to another control. for an example you can place the following code in the combo box selection change event, assuming you have another combobox:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    comboBox2.Focus();
}



另一个简单的方法是将以下代码放在表单Paint事件中。


Another simple method is to place the following code in your forms Paint event.

private void myForm_Paint(object sender, PaintEventArgs e)
{
    comboBox1.SelectionLength = 0;
}

实际上没有内置的方法可以满足您的要求,而且我已经看到了许多对于这种简单效果而言变得相当大的工作。上面的方法就是我要用的。



祝你好运。

There really isn't a built in method for doing what you ask and I've seen numerous work arounds that become rather large for such a simple effect. The methods above are what I would use.

Good luck.


在css中添加此代码



ADD this code in css

*:focus
{
    outline: none;
}


这篇关于如何在组合框中禁用高亮显示选定的项目C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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