c#判断赋值问题
环境:c#2008+sql2000 我要实现一个工具栏权限控制,在主窗体上有一工具栏,里面有很多按钮,如添加,删除,修改,浏览等 如果这个用户的添加权限是"Y",那么添加按钮是可用的,反之不能用。 我想用一行语句来实现这个功能 this.ButtonAdd.Enabled={if(strBool=="Y"){return true;}else{return false;}}; 但我这样写是不对的,请问这里的高人该怎么写呢。 这里的strBool是从数据库中读出来的,只有两种值“Y”或“N” 我要导出DataGridView的数据到Excel,应该怎么引用Excel呢 先在这里谢谢各位了
this.ButtonAdd.Enabled= strBool=="Y" ?true:false; this.ButtonAdd.Enabled = (strBool=="Y")? true : false; 简单的说,先给按钮编码 再做一个对应的东西 用表也可以,用字符串也可以 根据用户的ID和按钮的编码就能找对应的权限 还有就是分组分角色来控制 不理解为什么用返回bool值的三目运算符 引用 this.ButtonAdd.Enabled = (strBool=="Y")? true : false; up引用 this.ButtonAdd.Enabled= strBool=="Y" ?true:false;引用 不理解为什么用返回bool值的三目运算符 楼主可能是想实现对多个按扭的控制,比如: this.ButtonAdd.Enabled = (strAdd == "Y")? true : false; this.ButtonEdit.Enabled = (strEdit == "Y")? t
相关问答:
DataSet导出xml 批处理(循环)得怎么处理 XML文件 <A> <B> <C> </C> &nb ......
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using Syst ......
我用jquery无刷新上传图片后返回json格式的数据报错 (实际上图片是上传成功的了,只是返回json格式总读不到,总是报错) 我调试上传的ashx页如下 无法显示 XML 页。 使用 样式表无法查看 XML 输入。请更 ......
我写了一个C#应用程序,需要向PHP页面提交一段加密的数据。C#用的DES加密算法。算法如下:C# code: public class Crypt { /// <summary> /// 创建Key /// </su ......
我有一个类似的xml的 string,想通过遍历怎么个xml 输出我想要的element的值 xml 为: <Discover xmlns="urn:schemas-microsoft-com:xml-analysis"> <RequestType>DISCOVER_XML_ME ......