編集中にフォームの閉じるボタンをクリックすると他のコントロールにフォーカスが移動する
対象製品
MultiRow for Windows Forms 5.0J
状況
修正済み
詳細
GcMultiRowコントロールのセルを編集中の状態でフォームの右上の「閉じる」ボタンをクリックした際にフォームのFormClosingイベントでイベントのキャンセルを行うと、フォーカスがフォーム上の一番TabIndexの小さいコントロールに移動します。
回避方法
この現象はService Pack 2 (v5.0.2011.0513)で修正されています。
最新のService Packのダウンロードはこちら 。
または、FormClosingイベントの代わりにForm.WndProcイベントを使用することで回避することが可能です。
[Visual Basic]
Imports GrapeCity.Win.MultiRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GcMultiRow1.Template = Template.Default
End Sub
' 【回避方法 1/2】 FormClosingイベントをコメントアウトします。
'Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
' If MessageBox.Show("フォームを閉じますか?", "", MessageBoxButtons.YesNo) = DialogResult.No Then
' e.Cancel = True
' End If
'End Sub
' 【回避方法 2/2】 FormClosingイベントの代わりにWndProcイベントを使用します。
Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_SYSCOMMAND As Integer = &H112
Const SC_CLOSE As Integer = &HF060
If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32() = SC_CLOSE Then
If TypeOf Me.ActiveControl Is IEditingControl Then
TryCast(Me.ActiveControl, IEditingControl).GcMultiRow.EndEdit()
End If
If MessageBox.Show("フォームを閉じますか?", "", MessageBoxButtons.YesNo) = DialogResult.No Then
If TypeOf Me.ActiveControl Is GcMultiRow Then
TryCast(Me.ActiveControl, GcMultiRow).BeginEdit(False)
End If
Return
End If
End If
MyBase.WndProc(m)
End Sub
[C#]
using GrapeCity.Win.MultiRow
private void Form1_Load(object sender, EventArgs e)
{
gcMultiRow1.Template = Template.Default;
}
// 【回避方法 1/2】 FormClosingイベントをコメントアウトします。
//private void Form1_FormClosing(object sender, FormClosingEventArgs e)
//{
// if (MessageBox.Show("フォームを閉じますか?", "", MessageBoxButtons.YesNo) == DialogResult.No)
// {
// e.Cancel = true;
// }
//}
// 【回避方法 2/2】 FormClosingイベントの代わりにWndProcイベントを使用します。
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_CLOSE)
{
if (this.ActiveControl is IEditingControl)
{
(this.ActiveControl as IEditingControl).GcMultiRow.EndEdit();
}
if (MessageBox.Show("フォームを閉じますか?", "", MessageBoxButtons.YesNo) == DialogResult.No)
{
if (this.ActiveControl is GcMultiRow)
{
(this.ActiveControl as GcMultiRow).BeginEdit(false);
}
return;
}
}
base.WndProc(ref m);
}
最新のService Packのダウンロードはこちら 。
または、FormClosingイベントの代わりにForm.WndProcイベントを使用することで回避することが可能です。
[Visual Basic]
Imports GrapeCity.Win.MultiRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GcMultiRow1.Template = Template.Default
End Sub
' 【回避方法 1/2】 FormClosingイベントをコメントアウトします。
'Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
' If MessageBox.Show("フォームを閉じますか?", "", MessageBoxButtons.YesNo) = DialogResult.No Then
' e.Cancel = True
' End If
'End Sub
' 【回避方法 2/2】 FormClosingイベントの代わりにWndProcイベントを使用します。
Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_SYSCOMMAND As Integer = &H112
Const SC_CLOSE As Integer = &HF060
If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32() = SC_CLOSE Then
If TypeOf Me.ActiveControl Is IEditingControl Then
TryCast(Me.ActiveControl, IEditingControl).GcMultiRow.EndEdit()
End If
If MessageBox.Show("フォームを閉じますか?", "", MessageBoxButtons.YesNo) = DialogResult.No Then
If TypeOf Me.ActiveControl Is GcMultiRow Then
TryCast(Me.ActiveControl, GcMultiRow).BeginEdit(False)
End If
Return
End If
End If
MyBase.WndProc(m)
End Sub
[C#]
using GrapeCity.Win.MultiRow
private void Form1_Load(object sender, EventArgs e)
{
gcMultiRow1.Template = Template.Default;
}
// 【回避方法 1/2】 FormClosingイベントをコメントアウトします。
//private void Form1_FormClosing(object sender, FormClosingEventArgs e)
//{
// if (MessageBox.Show("フォームを閉じますか?", "", MessageBoxButtons.YesNo) == DialogResult.No)
// {
// e.Cancel = true;
// }
//}
// 【回避方法 2/2】 FormClosingイベントの代わりにWndProcイベントを使用します。
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_CLOSE)
{
if (this.ActiveControl is IEditingControl)
{
(this.ActiveControl as IEditingControl).GcMultiRow.EndEdit();
}
if (MessageBox.Show("フォームを閉じますか?", "", MessageBoxButtons.YesNo) == DialogResult.No)
{
if (this.ActiveControl is GcMultiRow)
{
(this.ActiveControl as GcMultiRow).BeginEdit(false);
}
return;
}
}
base.WndProc(ref m);
}
キーワード
MLTR07623