Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1878
Icons Refresh issue
posted

Hi,

Among many other thing I'm using the WinGrid for displaying Orders coming from our Online Shop. Each row shows order related information that is coming out from a C# business object using data binding. There are also some icons displayed for each order like if the Order is an Upgrade, if it has been originated by one of our Resellers etc. Those icons are set in the InitializeRow event of the Grid with code like depicted in following snippet:

private void OnOrdersGridInitializeRow(object sender, InitializeRowEventArgs e)

{

   /// Get the Order business object for that row
  var order = e.Row.ListObject as Order;

  if (order != null)
  {
     UltraGridCell upgradeCell = e.Row.Cells["IsUpgradeCell"];
     upgradeCell.Appearence = order.IsUpgrade ? grid.DisplayLaout.Appearances["UpgradeAppearance"] : null;

  }

}

The appearance is set in the InitializeLayout event like depicted below:

private void OnOrdersGridInitializeLayout(object sender, InitializeLayoutEventArgs e)

{
   Appearance isUpgradeAppearance = e.Layout.Appearances.Add["UpgradeAppearance"];
   isUpgradeAppearance.ImageBackground = Resources.IsUpgrade;
}

That all works perfectly fine but we also have a toolbar button allowing Sales staff to refresh the Grid so that newly arrived Orders coming from Online Shop are displayed. If they process an Order from top of the Grid and the Order will be removed from the Grid because it moves to another state this works still fine, the remaining Orders still show correct icons but as soon as the Grid is refreshed with new data from the database some of the icons are displayed wrong so e.g. the icon for Upgrade is not shown for an order although this order didn't change, showed the Upgrade icon before the Refresh. Basically the code couldn't be wrong otherwise it never would work but it is only not working correctly when the binding source is newly set.

Here is the code snippet when the Orders have been fetched from the database:

// Set the data source of binding source with the list of Orders received from the database
orderBindingSource = fetchedOrdersFromDatabase;

// Make sure that InitializeRow event is fired otherwise the icons are not displayed appropriately
ordersGrid.Rows.Refresh(Refresh.FireInitializeRow, true);

orderBindingSource is a MS BindingSource used by the WinGrid for data binding, ordersGrid is the WinGrid object.

Could it be an issue because I'm calling the Refresh-method immediately after the binding source has been newly set? Is it necessary to wait for an event before calling Refresh or is there another preferred mechanism to be used to initialized displaying the icons compared to FireInitializeRow?

Thanks in advance,

Wolfgang

Parents Reply Children
No Data