他コントロールのValidatingイベントでe.Cancelを有効にしてもGcButtonのイベントが発生する
対象製品
PlusPak for Windows Forms 7.0J
状況
修正済み
詳細
GcButton押下時に他コントロールの Validatingイベントが呼ばれた場合、その Validatingイベント内で Cancelプロパティを Trueに設定しても GcButtonの Clickイベントが呼び出されてしまいます。
回避方法
この問題はService Pack 2(v7.0.2014.0423)で修正されました。
不具合を修正した最新のサービスパックは、アップデートページ からダウンロードできます。
また、次の方法で回避することができます。
GcButtonの Clickイベント内の処理を GcButtonにフォーカスがあるときのみ実行します。
[Visual Basic]
Private Sub TextBox1_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If TextBox1.Text = "100" Then
System.Diagnostics.Debug.WriteLine("TextBox1_Validating")
e.Cancel = True
End If
End Sub
Private Sub GcButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GcButton1.Click
'System.Diagnostics.Debug.WriteLine("GcButton1_Click")
' フォーカスがあるときのみ処理を実行します。
If GcButton1.Focused Then
System.Diagnostics.Debug.WriteLine("GcButton1_Click")
End If
End Sub
[C#]
private void textBox1_Validating(object sender, CancelEventArgs e)
{
if (textBox1.Text == "100")
{
System.Diagnostics.Debug.WriteLine("textBox1_Validating");
e.Cancel = true;
}
}
private void gcButton1_Click(object sender, EventArgs e)
{
//System.Diagnostics.Debug.WriteLine("gcButton1_Click");
if (gcButton1.Focused)
{
System.Diagnostics.Debug.WriteLine("gcButton1_Click");
}
}
不具合を修正した最新のサービスパックは、アップデートページ からダウンロードできます。
また、次の方法で回避することができます。
GcButtonの Clickイベント内の処理を GcButtonにフォーカスがあるときのみ実行します。
[Visual Basic]
Private Sub TextBox1_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If TextBox1.Text = "100" Then
System.Diagnostics.Debug.WriteLine("TextBox1_Validating")
e.Cancel = True
End If
End Sub
Private Sub GcButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GcButton1.Click
'System.Diagnostics.Debug.WriteLine("GcButton1_Click")
' フォーカスがあるときのみ処理を実行します。
If GcButton1.Focused Then
System.Diagnostics.Debug.WriteLine("GcButton1_Click")
End If
End Sub
[C#]
private void textBox1_Validating(object sender, CancelEventArgs e)
{
if (textBox1.Text == "100")
{
System.Diagnostics.Debug.WriteLine("textBox1_Validating");
e.Cancel = true;
}
}
private void gcButton1_Click(object sender, EventArgs e)
{
//System.Diagnostics.Debug.WriteLine("gcButton1_Click");
if (gcButton1.Focused)
{
System.Diagnostics.Debug.WriteLine("gcButton1_Click");
}
}
キーワード
PPWI08129