简体   繁体   English

c# 单击按钮时如何打开 combobox

[英]c# How do I open the combobox when the button is clicked

private void button1_Click(object sender, EventArgs e) { 
cb_brand_Click(cb_brand, new EventArgs());
}

detected as clicked, but not detected as a directory after adding and refreshing the data I typed检测为单击,但在添加和刷新我键入的数据后未检测为目录

Hi you can try this,你好,可以试试这个

private void button1_Click(object sender, EventArgs e)
    {
        comboBox1.Focus();
        comboBox1.DroppedDown = true;
    }

I'm not sure exactly what you are wanting to do but this should open ComboBox1 so you could put it in your on click event of the button.我不确定您到底想要做什么,但这应该打开 ComboBox1 以便您可以将其放入按钮的单击事件中。 obviously change the name of ComboBox1 to whatever your combo box is called.显然将 ComboBox1 的名称更改为您的组合框的名称。

ComboBox1.DroppedDown = !ComboBox1.DroppedDown;

use this用这个

private void button1_Click(object sender, EventArgs e) { 
    comboBox1.DroppedDown = true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击按钮时如何选择随机对象? C#XAML Win Store应用程序 - How do I select a random object when a button is clicked? C# XAML Win Store App 如何知道何时在C#中单击按钮 - How to know when a button is clicked in C# 我在datagridview中添加了更新按钮,当在C#中单击按钮时,如何更改文本? - i have added update button inside datagridview how to change text on it when button is clicked in c#? 当我在C#中重新打开表单时如何获取选定的组合框项目和按钮上的文本 - How to get selected combobox items and text on button when I reopen the form in C# 重新打开表单时不使用C#时如何获取选定的组合框项目和按钮上的文本 - How to get selected combobox items and text on button when I reopen the form without using serialization in C# (C# WPF)单击menuA中的MenuItem时如何打开menuB - (C# WPF) How to open menuB when MenuItem in menuA is clicked 我可以在c#中删除标签richtextbox吗? 单击按钮时? - Can I remove a label, richtextbox in c#? when a button is clicked? 如何检查单击了哪个按钮? Visual Studio C# - How do I check which button is being clicked? Visual Studio C# C# DateTimePicker,单击上下按钮时如何检测事件? - C# DateTimePicker, how can I detect events when up-down button was clicked? 在 wpf C# 中单击按钮时如何禁用其他功能 - how to disable the other functions when Button clicked in wpf C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM