传递一个控件名称作为变量,然后使用该变量隐藏一个控件。

huangapple go评论46阅读模式
英文:

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;

huangapple
  • 本文由 发表于 2023年1月9日 00:07:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75049301.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定