0

新しい値を受け入れる必要があるグリッドに LookupEdit があります。新しい値を入力して「Enter」または「Tab」を押すと、通常は ProcessNewValue イベントを介して保存されますが、値を入力してグリッドの他の場所、別のセル、または空白をクリックすると、値が完全に消えます. 他のいくつかのイベントを実装し、ブレークポイントを設定することで、「CloseUp」イベントが発生する前に値が消えることがわかりました。Validating、EditValueChanged、EditValueChanging、ProcessNewValue、Closed、Leave、および GetNotInListValue でさえ、値が空のために呼び出されることはありません。

私がまだ見つけていない設定、またはこの値が消える他の理由を誰か思いつくことができますか...そして、どうすればそれを防ぐことができますか?

有効な回避策が見つかりました

この問題を解決するために、次の 3 つのイベントを順番に実装しました。何が原因なのか、それを防ぐ方法はまだわかりません。これは回避策であり、解決策ではなく、そのように扱う必要があります。メソッドを手動で呼び出すProcessNewValueだけでなく、値を強制的にテキスト フィールドと等しくし、後でテキスト フィールドを値に戻す必要があります。最もスムーズな操作ではありませんが、機能します。

private void repPatchNum1_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
    {
        string surfaceSoftware = vwSurfaceSoftware.GetRowCellDisplayText(vwSurfaceSoftware.FocusedRowHandle, "SurfaceSoftware");
        if (string.Compare(surfaceSoftware, SOFTWARE_CHECK, true) == 0)
        {
            string version = vwSurfaceSoftware.GetRowCellDisplayText(vwSurfaceSoftware.FocusedRowHandle, "Version");
            if (version.ToLower().Contains(VERSION_CHECK))
            {//now we are certain we are in the right place
                LookUpEdit editor = sender as LookUpEdit;
                if (!((RPickListCollection)((BindingSource)editor.Properties.DataSource).DataSource).OfType<RPickList>().Any(a => a.RValue.Equals(e.NewValue)))
                {
                    repPatchNum1_ProcessNewValue(sender, new DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs(e.NewValue));
                    vwSurfaceSoftware.SetRowCellValue(vwSurfaceSoftware.FocusedRowHandle, colPatchNum, e.NewValue);
                }
            }
        }
    }

    private void repPatchNum1_CloseUp(object sender, DevExpress.XtraEditors.Controls.CloseUpEventArgs e)
    {
        string surfaceSoftware = vwSurfaceSoftware.GetRowCellDisplayText(vwSurfaceSoftware.FocusedRowHandle, "SurfaceSoftware");
        if (string.Compare(surfaceSoftware, SOFTWARE_CHECK, true) == 0)
        {
            string version = vwSurfaceSoftware.GetRowCellDisplayText(vwSurfaceSoftware.FocusedRowHandle, "Version");
            if (version.ToLower().Contains(VERSION_CHECK))
            {//now we are certain we are in the right place
                LookUpEdit editor = sender as LookUpEdit;
                if (!((RPickListCollection)((BindingSource)editor.Properties.DataSource).DataSource).OfType<RPickList>().Any(a => a.RValue.Equals(e.Value)))
                {
                    e.Value = ((LookUpEdit)sender).Text;
                }
            }
        }
    }

    private void repPatchNum1_Closed(object sender, DevExpress.XtraEditors.Controls.ClosedEventArgs e)
    {
        string surfaceSoftware = vwSurfaceSoftware.GetRowCellDisplayText(vwSurfaceSoftware.FocusedRowHandle, "SurfaceSoftware");
        if (string.Compare(surfaceSoftware, SOFTWARE_CHECK, true) == 0)
        {
            string version = vwSurfaceSoftware.GetRowCellDisplayText(vwSurfaceSoftware.FocusedRowHandle, "Version");
            if (version.ToLower().Contains(VERSION_CHECK))
            {//now we are certain we are in the right place
                LookUpEdit editor = sender as LookUpEdit;
                string patch = vwSurfaceSoftware.GetRowCellValue(vwSurfaceSoftware.FocusedRowHandle, colPatchNum).ToString();
                if (String.IsNullOrEmpty(editor.Text) && !String.IsNullOrEmpty(patch))
                {
                    editor.Text = vwSurfaceSoftware.GetRowCellValue(vwSurfaceSoftware.FocusedRowHandle, colPatchNum).ToString();
                    vwSurfaceSoftware.UpdateCurrentRow();
                }
            }
        }
    }

元の質問について:なぜこれが起こっているのか、またはそれを防ぐ方法がわかっている場合は、回答を投稿してください。

皆さんありがとう :-)

4

1 に答える 1