controls visibility in C#

 ̄綄美尐妖づ 提交于 2019-12-13 05:08:40

问题


How to make a control visibilty to true or false. currently i am setting a panel control visibility like this in code behind. i am comparing the values of Username and UserId. If both the values are same..i am setting panel visibility to false

               if (UserName == UserID))
                {
                    pnl_linkbuttons.Visible = false;
                }

is there any alternative way to set the control visibility in C# from code behind.

Thanks in advance.


回答1:


pnl_linkbuttons.Visible = UserName == UserID;



回答2:


if you are using asp.net you could use jQuery or javascript, but if youre working in windows forms you pretty much need to use C#.

if you were in silverlight or wpf you could set the visibility using XAML.

try this link for reference if youre in XAML... How can you get a XAML TextBlock to collapse when it contains no data?

or here in MSDN... http://msdn.microsoft.com/en-us/library/system.windows.trigger.aspx



来源:https://stackoverflow.com/questions/3827911/controls-visibility-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!