Skip to content

Commit

Permalink
测试聚焦
Browse files Browse the repository at this point in the history
  • Loading branch information
zzy-life committed Oct 30, 2024
1 parent 205255f commit a5bf5cd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Desktop Notes/Desktop Notes/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public MainForm(int id, FormData dat = null)
g.FillRectangle(brush, 0, 0, sureDialog.Width, sureDialog.Height);
sureDialog.BackgroundImage = image;
sureDialog.BackgroundImageLayout = ImageLayout.Stretch;

this.notebox1.Enter += new EventHandler(notebox1_Enter); // 添加这一行
}

private void LoadData(FormData dat = null)
Expand Down Expand Up @@ -288,6 +290,7 @@ private void deleteNote_Click(object sender, EventArgs e)
{
// 切换 notebox1 的 ReadOnly 属性
notebox1.ReadOnly = !notebox1.ReadOnly;
notebox1.TabStop = !notebox1.ReadOnly;

// 显示当前状态
if (notebox1.ReadOnly)
Expand All @@ -300,6 +303,15 @@ private void deleteNote_Click(object sender, EventArgs e)
}
}

// 禁止控件在只读状态时聚焦
private void notebox1_Enter(object sender, EventArgs e)
{
if (notebox1.ReadOnly)
{
this.SelectNextControl(notebox1, true, true, true, true);
}
}

private void settings_Click(object sender, EventArgs e)
{
SettingForm setting = new SettingForm(this);
Expand Down

0 comments on commit a5bf5cd

Please sign in to comment.