Search code examples
c#winformsjanus

Janus GridEX Not refreshing


I am using the Janus GridEX in a solution. I have a refresh button on the screen. The idea of this refresh button is obviously to get new data from the datastore. When the user clicks this button once it does not refresh the grid, but when you click the button a second time then the grid refreshes. Here is how I populate the grid on this button click

    public void PopulateDashboard()
    {
        List<DashboardReminder> reminders = DashboardReminder.GetReminders(1, true);
        grdDashboard.SetDataBinding(reminders, "RootTable");

    }

I have tried all combinations of refresh, tried with a binding source, but can not get this button to work the first time the user clicks on it, no matter how i bind this gridview to my list of objects.

Please any ideas are welcome.

regards


Solution

  • There's a couple of different things you could try

    1)

     public void PopulateDashboard()
     {
         grdDashboard.SetDataBinding(Nothing, Nothing)
         List<DashboardReminder> reminders = DashboardReminder.GetReminders(1, true);
         grdDashboard.SetDataBinding(reminders, "RootTable");
     }
    

    2)

     BindingList<DashboardReminder> reminders;
     public void Setup()
     {
         grdDashboard.SetDataBinding(reminders, "RootTable");
     }
     public void FetchReminders()
     {
         BindingList<DashboardReminder> reminders2 = DashboardReminder.GetReminders(1, true);
         //add your own code to import contents of reminders2 into reminders
     }
    

    The Janus grid will automatically notice the ListChanged events fired from the reminders BindingList and correctly update the display.

    If you go with the BindingList option, you get all the list changed events for free and you don't have to worry about calling Grid.Refetch or re-binding just to update the display. You should only need to call Grid.SetDataBinding(a,b) once, after that just manipulate the underlying list.