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
1863
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
  • 21795
    Offline posted

    Hello Wolfgang,

    Thank you for posting in our forum.

    If I understand you correctly these are the steps you have performed:

       1. You are creating an MS BindingSource and set its data source to some collection of orders.

       2. You set the grid data source to this MS BindingSource.

       3. Then you set some cells’ appearance depending on the cells’ value.

       4. You perform some action on the rows and cells in the grid.

       5. You set a new data source to your MS BindingSource.

    Actually step one and step five should result in same behavior. In each row the cell IsUpgradeCell will have the custom appearance if the value of the cell is true. As you wrote if this works first time it should work and the second time. The only reason I can think of, why you are receiving wrong cells is if the data you are retrieving form the back end data server is correct. Can you please check if the data which you are retrieving on refresh button click is correct?

    Please find attached also a small sample project I have created while was trying to reproduce this behavior with no success. Please try to modify this sample in order to demonstrate the behavior you are describing and send it back to me to investigate this further.

    Looking forward to your reply.

    Thank you for using Infragistics Components.

    CAS-167054-W9X9T4.zip
Reply Children