周一至周五 : 08:30 - 17:30 客服专员电话/微信:17301649371 QQ:2627049059
微信咨询

扫码微信咨询

关注公众号

关注微信公众号

电话: 021 5161 9370
返回顶部
验证输入密码解锁字段
显示全部楼层 倒序浏览 发表日期 2023-12-14 12:55:52 283次阅读 0次回复
bj_zm
2023-12-14 12:55:52
本帖最后由 bj_zm 于 2023-12-14 12:57 编辑

效果:
20231214125304.png

  1.                 Public Sub ButtunClick(sender As Object, e As SpreadsheetGear.Windows.Controls.ShapeActionEventArgs)
  2.                         If e.Shape.Name = "Button 1" Then
  3.                                 '填写符合条件后执行的代码
  4.                                 Dim W As New C1Window, Childs As New Grid,TB As New TextBlock, PassBox As New PasswordBox, OKButton As New Button
  5.                                 '内部控件
  6.                                 TB.Text = "请输入密码:"
  7.                                 TB.Margin = New Thickness(50, 40, 0, 0)
  8.                                 Childs.Children.Add(TB)'向窗口添加文字控件
  9.                                 PassBox.Width = 300
  10.                                 PassBox.Height = 28
  11.                                 PassBox.VerticalContentAlignment = VerticalAlignment.Center
  12.                                 PassBox.VerticalAlignment = VerticalAlignment.Top
  13.                                 PassBox.Margin = New Thickness(0, 60, 0, 0)
  14.                                 Childs.Children.Add(PassBox)'向窗口添加密码控件
  15.                                 OKButton.Width = 60
  16.                                 OKButton.Height = 28
  17.                                 OKButton.content = "确定"
  18.                                 OKButton.VerticalAlignment = VerticalAlignment.Bottom
  19.                                 OKButton.Margin = New Thickness(0, 0, 0, 30)
  20.                                 AddHandler OKButton.Click, Sub(ss, ee)
  21.                                         If PassBox.password <>"123" Then
  22.                                                 C1MessageBox.Show("密码错误!", "提示", OK, C1MessageBoxIcon.Warning)
  23.                                                 Return
  24.                                         End If
  25.                                         '解锁单元格
  26.                                         ev.GetLock
  27.                                         ev.ActiveWorksheet.ProtectContents = False
  28.                                         range("C4").Locked = False
  29.                                         ev.ActiveWorksheet.ProtectContents = True
  30.                                         ev.ReleaseLock
  31.                                         '关闭窗口
  32.                                         W.Close()
  33.                                 End Sub
  34.                                 Childs.Children.Add(OKButton)'向窗口添加按钮控件
  35.                                 '窗体设置
  36.                                 W.Style = CType(Application.Current.Resources("C1WindowStyle"), Style)'风格
  37.                                 W.Height = 200'高
  38.                                 W.Width = 400'宽
  39.                                 W.Header = "验证密码"'标题
  40.                                 W.Content = Childs
  41.                                 W.ShowMaximizeButton = False'最大化
  42.                                 W.ShowMinimizeButton = False'最小化
  43.                                 W.IsResizable = False'调整尺寸
  44.                                 W.CenterOnScreen()'居中
  45.                                 W.ShowModal()'显示
  46.                         End If
  47.                 End Sub'按钮/标签点击事件
复制代码



QQ:34840397
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则  允许回帖邮件提醒楼主

快表软件是国内较早研究表格类软件开发平台的团队之一,迄今已有十多年的行业经验.致力于为企事业单位提供实用可靠的数字化平台。
  • 微信公众号

  • 微信小商店

  • 微信客服

  • Powered by Discuz! X3.4 | Copyright © 2022-2024, XiRong Soft. | 快表软件
  • 沪ICP备13033196号 | 营业执照 |上海西戎软件科技有限公司|沪公网安备31011502002146号|沪ICP备13033196号 |