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
1640
Cell content issues
posted

We have two situations where we are modifying cell content and/or properties, and not getting the result we are looking for, as follows:

1. We want to be able to selectively hide and/or show grid columns (after the grid has been initialized) on auto fit grids.  Our existing logic works fine - it sets the widths properly and the grid auto-sizes correctly.  The problem is that the formerly hidden column is displayed with a grey (disabled) color.  I can change the ForeColor and ForeColorDisabled properties to black, but then the cell contents will be also be black on the highlighted row.  How can we revert the row to normal fore colors?

2. We want to display buttons in a grid column only on certain rows, and have the button cell be blank on the other rows.  So I have defined the button column initially with style = Default, and then change it to Button when I load the image.  But my routine is not working - the buttons do not appear at all - how should this be fixed?

public static void SetGridCellImage(UltraGridRow row, string columnName, object image = null)

{

    try

    {

        if (row != null && !string.IsNullOrWhiteSpace(columnName))

        {

            UltraGridCell cell = row.Cells[columnName];

            if (cell != null)

            {

                cell.Column.Style = (image == null)

                    ? Infragistics.Win.UltraWinGrid.ColumnStyle.Default : Infragistics.Win.UltraWinGrid.ColumnStyle.Button;

                

                                 cell.ButtonAppearance.Image = image;

            }

        }

    }

    catch

    {

    }

}

Parents
No Data
Reply
  • 21795
    Offline posted

    Hello Richard,

    Thank you for posting in our forum.

    Please find bellow the answers to your questions:

       1. I followed the steps you suggested and was unable to reproduce the behavior you're describing. I have attached the sample project I used to test this. Please in order to be able to further investigate can you please give me more information about: how exactly you are hiding the columns; how you display back the hidden columns; how you have set the AutoFitStyle property of your Grid; how you set the columns width. It will help if you can send me a small isolated sample solution.

       2. In your SetGridCellImage method you are actually set the Column style here cell.Column.Style. In order to set the cell style you need to change your code like this:

    cell.Style = (image == null) ?

    Infragistics.Win.UltraWinGrid.ColumnStyle.Default :

    nfragistics.Win.UltraWinGrid.ColumnStyle.Button;

    Please check attached sample solution where I have implement this approach.

    Waiting for your feedback.

    Thank you for using Infragistics Controls

    CAS-150472-S9V9P1.zip
Children