Thursday, November 27, 2008

C# .NET force control to refresh programatically

public partial class MainWindow : Form
{
List _latestPriceList = new List();
public MainWindow ()
{
    InitializeComponent();
    

    // Set the DataSource property of the ListBox called priceListBox1
    priceListBox1.DataSource = _latestPriceList;
}

}


private void AddNewPrice(double newprice)
{
    // Insert the string at the front of the List.
    _latestPriceList.Insert(0, newprice);

    // Force a refresh of the ListBox.
         ((CurrencyManager)priceListBox1.BindingContext[_latestPriceList]).Refresh();
}

No comments: