WinUI | ComponentOne
Controls / FlexGrid / Data / Live Updates
In This Topic
    Live Updates
    In This Topic

    FlexGrid lets you show rapidly updating information in your grid such as stock prices, sports scorecards, parking lots, hospital dashboards etc. The FlexGrid control supports binding to observable collections that automatically reflect any changes to the underlying data source.

    To mimic the real time data, we have implemented a dummy data source in the form of BindingList which contains data items that notify the change in data values through INotifyPropertyChanged interface. Create a class which implements INotifyPropertyChanged interface and represents the data item. In this case, we have used a class named Customer (available at the \Documents\ComponentOne Samples\WinUI\CS\Grid\FlexGridExplorer location). You can bind the FlexGrid to this data source using ItemsSource property of the FlexGrid class.

    C#
    Copy Code
    _customers = Customer.GetCustomerList(10);
    grid.ItemsSource = _customers;
    

    The FlexGrid control provides the AutoGeneratingColumn event to display on the grid frequent variations happening in the data source.

    C#
    Copy Code
    private void OnAutoGeneratingColumn(object sender, GridAutoGeneratingColumnEventArgs e)
    {
        var columns = new string[] { "FirstName", "LastName", "Country", "City" };
        if (!columns.Contains(e.Property.Name))
            e.Cancel = true;
        e.Column.Width = new GridLength(1, GridUnitType.Star);
        e.Column.MinWidth = double.NaN;
    }
    

    Now, as the grid is bound and is receiving notifications about changes in data values, it is capable of updating the real time data automatically.

    Please note that the LiveUpdates samples get added at Documents\ComponentOne Samples\WinUI\CS\Grid location while installing the WinUI Edition using the ComponentOneControlPanel.