wpf PasswordBox 样式中怎么用Password的值做为触发器
xaml中绑定://table表中的字段xaml.cs:string con = "Provider=System.Data.SqlClient;Data Source=.;database=logistics;User ID=sa;Password=sa123";SqlConnection sCon = new SqlConnection(con);sCon .Open();string sql = "select * from table";DataTable dt = new DataTable();SqlDataAdapter da=new SqDataAdapter(sql,sCon );DataSet ds=new DataSet();ds.Fill(ds,"dtName");dataGrid1.ItemsSource = ds.Tables["dtName"].DefaultView;
C#中如何写一个函数获取PasswordBox中输入的值
展开全部 获取passwordBoxPassword中密码的代码如下:// 使用一个IntPtr类型值来存储加密字符串的起始点IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(this.passwordBoxPassword.SecurePassword);// 使用.NET内部算法把IntPtr指向处的字符集合转换成字符串string password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);// 顺便校验一下if (string.IsNullOrEmpty(password) || password!="123456"){ MessageBox.Show("请输入密码", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); return;}注意:如果程序中的PasswordBox比较多,建议提前引用System.Runtime.InteropServices名称空间。
...
转载请注明出处51数据库 » wpf password