在窗口中放了一个记录窗口,设定的是第一列为空时不允许保存,按钮点保存时(选中非第一列,第一列为空)会提示警告窗口不允许保存,
用快捷键F2时(选中非第一列,第一列为空)不会提示,会直接保存一条新的记录????
如果记录窗口中是编辑状态(光标闪动)就会生效,选中状态提示就不生效???
怎么把记录窗口改为,选中就进入编辑状态??
保存按钮click中代码
【
'窗口变量,编辑状态
Dim bianji As String=e.Form.Controls("bianji").text
With Tables("yonghu")
If .Current("yhdm")="" Then
If MessageBox.Show(.Cols("yhdm").Caption+"不能为空!","警告",MessageBoxButtons.ok,MessageBoxIcon.Question) = DialogResult.ok Then
End If
'新增或者修改时默认选中第一行第一列,并进入编辑状态
e.Form.Controls("you1").BaseControl.Row=0
e.Form.Controls("you1").BaseControl.Col=1
e.Form.Controls("you1").BaseControl.StartEditing
'新增或者修改时默认选中第一行第一列,并进入编辑状态
Else
.Current.Save() '保存后禁止编辑 其他相应按钮禁用
.AllowEdit = False
e.Form.Controls("baocun").Enabled =False '设置按钮状态
e.Form.Controls("quxiao").Enabled =False
e.Form.Controls("xinzeng").Enabled =True
e.Form.Controls("xiugai").Enabled =True
e.Form.Controls("shanchu").Enabled =True
e.Form.Controls("shuaxin").Enabled =True
e.Form.Controls("daochu").Enabled =True
e.Form.Controls("dayin").Enabled =True
e.Form.Controls("shezhi").Enabled =True
e.Form.Controls("guanbi").Enabled =True '设置按钮状态
e.Form.Controls("bianji").text="0" '窗口变量,编辑状态
End If
End With
】
表keydownedit事件中代码
【
If e.KeyCode = Keys.F2 Then
e.Form.Controls("baocun").PerformClick
End If
】
[此贴子已经被作者于2014-5-23 11:25:14编辑过]