Back to Devexpress

PopupBaseEdit.RefreshEditValue() Method

windowsforms-devexpress-dot-xtraeditors-dot-popupbaseedit-ee99f95d.md

latest6.1 KB
Original Source

PopupBaseEdit.RefreshEditValue() Method

Updates the editor’s value by copying a value from the editor’s popup window to BaseEdit.EditValue.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public virtual void RefreshEditValue()
vb
Public Overridable Sub RefreshEditValue

Remarks

For the PopupContainerEdit, the RefreshEditValue method fires the PopupContainerEdit.QueryResultValue event. This allows you to update the editor’s edit value when changes are made outside the editor’s popup window.

Example

In this example the PopupContainerEdit uses the PopupContainerControl that holds the GridControl with 5 columns. The second column's value in the selected row is a displayed text for the PopupContainerEdit.Clicking the 'Refresh Edit Value' button adds the 'Add' text to the selected grid cell in the underlying data source. Then the PopupBaseEdit.RefreshEditValue method is called. It instantly updates the editor's value by copying a value from the editor's popup window to BaseEdit.EditValue.

csharp
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EditValueRefresh
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
    }
}
csharp
namespace EditValueRefresh {

    partial class DataSet1 {
    }
}
csharp
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Localization;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;

namespace EditValueRefresh {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();
        }

        public void InitData() {
            for (int i = 0; i < 5; i++) {
                dataSet11.Tables[0].Rows.Add(new object[] { i, string.Format("FirstName {0}", i), i, imageList1.Images[i], DateTime.Today.AddDays(i), true });
                dataSet11.Tables[1].Rows.Add(new object[] { i, string.Format("FirstName {0}", i), i });
            }
        }

        private void Form1_Load(object sender, EventArgs e) {
            InitData();
        }

        private void popupContainerEdit1_QueryResultValue(object sender, DevExpress.XtraEditors.Controls.QueryResultValueEventArgs e) {
            e.Value = dataSet11.Tables[0].Rows[0]["FirstName"];
        }

        private void cmdRefreshEV_Click(object sender, EventArgs e) {
            DataRow row = dataSet11.Tables[0].Rows[0];
            row["FirstName"] += ", Add";
            popupContainerEdit1.RefreshEditValue();
        }
    }
}
vb
Imports Microsoft.VisualBasic
Imports System
Namespace EditValueRefresh

    Public Partial Class DataSet1
    End Class
End Namespace
vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms

Namespace EditValueRefresh
    Public Partial Class Form2
        Inherits Form
        Public Sub New()
            InitializeComponent()
        End Sub
    End Class
End Namespace
vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid.Localization
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid

Namespace EditValueRefresh
    Public Partial Class Form1
        Inherits XtraForm
        Public Sub New()
            InitializeComponent()
        End Sub

        Public Sub InitData()
            For i As Integer = 0 To 4
                dataSet11.Tables(0).Rows.Add(New Object() { i, String.Format("FirstName {0}", i), i, imageList1.Images(i), DateTime.Today.AddDays(i), True })
                dataSet11.Tables(1).Rows.Add(New Object() { i, String.Format("FirstName {0}", i), i })
            Next i
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            InitData()
        End Sub

        Private Sub popupContainerEdit1_QueryResultValue(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.QueryResultValueEventArgs) Handles popupContainerEdit1.QueryResultValue
            e.Value = dataSet11.Tables(0).Rows(0)("FirstName")
        End Sub

        Private Sub cmdRefreshEV_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdRefreshEV.Click
            Dim row As DataRow = dataSet11.Tables(0).Rows(0)
            row("FirstName") &= ", Add"
            popupContainerEdit1.RefreshEditValue()
        End Sub
    End Class
End Namespace

See Also

QueryResultValue

PopupBaseEdit Class

PopupBaseEdit Members

DevExpress.XtraEditors Namespace