英文:
pass a control name as a variable and then hide a control using that variable
问题
我正在编写一个函数,它将接收一个名为`showme`的变量,这个变量是一个(在这种情况下)`FlowLayoutPanel`的名称,并且我想使用这个变量来将特定的面板设为可见。
ps 我是C++的新手!
任何帮助将不胜感激。
以下代码未能工作
void JommSwitchPanels(FlowLayoutPanel^ showme)
{
    
    //在这里处理隐藏菜单面板的代码
    
    showme->Visible = true; // 在showme上显示错误
    
    flowfleet1->Visible = false;
    flowhr->Visible = false;
}
英文:
I'm building a function that will receive the name of a (in this case) FlowLayoutPanel as variable showme and I want to use this variable to set that particular panel visible.
ps I am new to c++ !
Any help would be greatly appreciated.
The following is not working
   void JommSwitchPanels(FlowLayoutPanel^ showme)
   {
	   
	   //stuff here to hide the menu panels
	   
	    showme.Visable = true;//the error is shown on showme
	    	   
	   flowfleet1->Visible = false;			   
	   flowhr->Visible = false;
   }
答案1
得分: -1
showme 是一个指向 FlowLayoutPanel 对象的句柄。在 c++/cli 中解引用一个对象句柄要使用箭头运算符 (->)。你还有一个属性名的拼写错误 (Visable/Visible)。
因此,你需要将:
showme.Visable = true;
改为:
//----vv--------------
showme->Visible = true;
英文:
showme is a handle to a FlowLayoutPanel object.
Dereferencing a handle to object in c++/cli is done using the arrow operator (->).
You also have a typo in the property name (Visable/Visible).
Therefore you need to change:
showme.Visable = true;
To:
//----vv--------------
showme->Visible = true;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论