在C ++的Windows窗体上从ComboBox读取值 [英] Reading Value from ComboBox on Windows Form in C++
问题描述
大家好,
我正在尝试实现一些使用包含下拉组合框的Windows窗体的代码充满价值。这些值描述了我希望将东西打印到日志的详细程度(即关键消息,错误消息,调试消息ec)
我想知道是否有一种让我的C ++类文件在Windows窗体上读取COMBOBOX值的方法?
即comboBox1 = dlCritical。
在日志文件类中:
iDebugLevels = comboBox1.value()? //我知道这实际上并没有用,但只是为了解释我在寻找什么。
文件系统的结构如下:
Hi Guys,
I''m trying to implement some code that uses a Windows Forms that contains a dropdown combobox that is filled with values. These values depict that level of detail i want stuff to be printed to a log (i.e. Critical messages, Error Messages, Debug Messages ec)
I am wondering if there is a way in which to get my C++ class file to READ the value of the COMBOBOX on the windows form?
i.e. comboBox1 = dlCritical.
In the logfile Class:
iDebugLevels = comboBox1.value()? // I know this doesn''t actually work but it''s just to explain what i''m looking for.
The structure of the file system is as follows:
<pre lang="c++">
main()
{
Applicatoin::Run(gcnew Form1());
}
public ref class Form1 : public System::Windows::Forms::Form
{
private: WinIO mWinIO;
public:
Form1(void)
{
InitializeComponent();
mWinIO = gcnew WinIO();
}
.....
}
WINIO CLASS:
WinIO::WinIO(void)
{
mLogFile = new LogFile();
}
LOGFILE CLASS:
LogFile::LogFile(void)
{
OpenLogFile("WINIO_LOGFILE.txt");
mDebugLevels = comboBox.Value(); //This is where i would like to read in the value of the combo box value from the form.
}
推荐答案
你应该使用属性System.Windows.Forms.ComboBox.Text
,这是当前在编辑区域中显示的值:
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows。 forms.combobox.text.aspx [ ^ ]。
-SA
You should use the propertySystem.Windows.Forms.ComboBox.Text
, which is the value currently presented in the edit area:
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.text.aspx[^].
—SA
这篇关于在C ++的Windows窗体上从ComboBox读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!