Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 增加下拉列表中建议的组合框中ListItem的字体大小_C#_Visual Studio_Combobox_Dropdown - Fatal编程技术网

C# 增加下拉列表中建议的组合框中ListItem的字体大小

C# 增加下拉列表中建议的组合框中ListItem的字体大小,c#,visual-studio,combobox,dropdown,C#,Visual Studio,Combobox,Dropdown,我在Visual Studio中使用C#创建桌面应用程序时使用了组合框,现在运行应用程序并单击下拉按钮列表元素时,我将字体大小增加到了“20”。 那很好。但是,当我在组合框中写一些东西时,它会给出如下图所示的建议。 一、 还想增加这个建议列表的字体大小,我已经将“AutoCompleteMode”属性设置为“suggest”。有人能帮我吗?这实际上是两个可以独立配置的领域。根据这篇MSDN文章 要更改设置,请执行以下操作: 转到工具–选项–环境–字体和颜色 在“显示设置”下:选择语句完成或编

我在Visual Studio中使用C#创建桌面应用程序时使用了组合框,现在运行应用程序并单击下拉按钮列表元素时,我将字体大小增加到了“20”。

那很好。但是,当我在组合框中写一些东西时,它会给出如下图所示的建议。


一、 还想增加这个建议列表的字体大小,我已经将“AutoCompleteMode”属性设置为“suggest”。有人能帮我吗?

这实际上是两个可以独立配置的领域。根据这篇MSDN文章

要更改设置,请执行以下操作:

  • 转到工具–选项–环境–字体和颜色
  • 在“显示设置”下:选择语句完成或编辑器工具提示(用于参数信息和快速提示)
  • 更改字体或字体大小

  • 显示的自动完成文本的字体是固定的。没有相应的属性来设置它

    一种解决方法是,您可以创建一个自定义控件,并用自定义列表框替换“建议”下拉列表

    public Form1()
    {
        InitializeComponent();
        comboBox1.Size = new Size(120, 30);
        listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;
    }
    
    private void ListBox_SelectedIndexChanged(object sender, EventArgs e)
    {
        comboBox1.Text = listBox.Text;
        listBox.Visible = false;
    }
    
    ListBox listBox = new ListBox();
    
    // event triggered when the user enters text
    private void comboBox1_TextUpdate(object sender, EventArgs e)
    {
        // set the font of listbox to be consistent with combobox
        listBox.Font = comboBox1.Font;
        // add listbox below combobox
        listBox.Location = new Point(comboBox1.Location.X, comboBox1.Location.Y + comboBox1.Height);
    
        // filter suggest items
        listBox.Items.Clear();
        foreach (string item in comboBox1.Items)
        {
            if (item.StartsWith(comboBox1.Text) && comboBox1.Text != string.Empty)
            {
                listBox.Items.Add(item);
            }
        }
    
        listBox.Visible = listBox.Items.Count > 0;
        this.Controls.Add(listBox);
    }
    
    测试结果:


    还是没有working@PUBG这对你有帮助吗?如果是的话,谢谢。这对我很有帮助。谢谢!