Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / UltraGrid Header Settings not working as expected

UltraGrid Header Settings not working as expected

New Discussion
Bhushan Inamdar
Bhushan Inamdar asked on Mar 14, 2016 10:45 AM

Hi,

I have a UltraGrid control in which, I am trying to do a few things as mentioned below…

I have an ultraGrid and ultraDataSource which are initialized and assigned to in the InitializeComponent() method of the parent. I have created individual dictionaries for UltraDataColumn and UltraGridColumn respectively.

– Firstly, I populate the Columns names array

– Secondly, I populate the data which is an array of class objects.

– Then I create a UltraDataColumn dictionary from the Columns array; but do not yet add it to UltraDatasource

– Next I create another dictionary of corresponding UltraGridColumns from the dictionary of UltraDataColumns, but do not yet add it to UltraGrid

– Since, now the column collections are ready and since the UltraDataSource is already bound to UltraGrid, the Grid Columns collection already has the column information

– Now, add the UltraGridColumns to UltraGrid and then add the UltraDataColumns to UltraDataSource.

– In Initialize_Layout event handler, I initialize layout, band and provide values to overrides and also format headers looping through the UltraGrid’s column collection

– In the Initialize_Layout, I am trying to set the 0th column that serves as row header as a Fixed Column, which is always visible and remains in position on scrolling. I have set Fixed property to true, FixedColumnIndicators to None yet the column does not fix itself. I have tried this setting in RowLayoutMode as GroupLayout as well as COlumnLayout respectively. But it still fails….

– I am able to set the appearance for the headers in Initialize_Layout. Everything, except BackColor is rendered properly. I have tried to find out as to what is causing the problem;

– I have multiple Ultra tabs on the UI and each tab has an UltraGrid. I am doing custom drawing of +/- signs in column headers to implement expandable Columns. I have assigned a creation filter to the grid. With some deal of research, I am able to provide +/- buttons in headerUI. However, the UltraGrid custom drawing is lost when the tab is changed and the same ultra Grid is shown again and it does show the grid without any formatting…

– Is there a way to fire InitializeLayout on purpose?

Please advice if I am doing anything wrong…

Thanks,

Bhushan.

Sign In to post a reply

Replies

  • 0
    Dimitar
    Dimitar answered on Mar 11, 2016 9:00 AM

    Hi Bhushan,

    Thank you for posting in our forums.

    • For the fixed headers, if they aren’t working, you probably need to set the UseFixedHeaders property of the DisplayLayout to true:

      this.ultraGrid1.DisplayLayout.UseFixedHeader = true;

    • For the Header color it is probably overridden by the style that the header uses. In order to override this use the following line:

      this.ultraGrid1.DisplayLayout.Override.HeaderStyle = HeaderStyle.Standard;

    • As for the CreationFilter, there really isn’t a way for me to know what is going on, unless I see your application. Most probably there is some issue in your CreationFilter, but without seeing it there is now way to know exactly what.

    • What do you mean by “Is there a way to fire InitializeLayout on purpose”? The event is fired when the grid is provided with a data source. If you want to call the code inside it multiple time, encapsulate the code inside the event in a method and then call the method.

    Please let me know if you have any additional questions.

    • 0
      Bhushan Inamdar
      Bhushan Inamdar answered on Mar 11, 2016 8:24 PM

      Hi Bhushan,

      Thank you for posting in our forums.

      • For the fixed headers, if they aren’t working, you probably need to set the UseFixedHeaders property of the DisplayLayout to true:

        this.ultraGrid1.DisplayLayout.UseFixedHeader = true;

      Yes. I have already set that property to true and also FixedHeaderIndicator option to none so that user shall not have an option to toggle the fixing of the column. However, I suspect that using custom CreationFilter to embed ExpansionIndicatorUIElement i.e., (+/-) signs in the Column Headers to Expand and Collapse the Columns, might be the reason to make this not work. Can you let me know if this could be possible. Also does setting of the layout to ColumnLayout or GroupLayout option have any impact on Fixed Headers? Trying to analyze this…
      • For the Header color it is probably overridden by the style that the header uses. In order to override this use the following line:

        this.ultraGrid1.DisplayLayout.Override.HeaderStyle = HeaderStyle.Standard;

      Yes and thanks. This line did it for me. Earlier, it was set to default.
      • As for the CreationFilter, there really isn’t a way for me to know what is going on, unless I see your application. Most probably there is some issue in your CreationFilter, but without seeing it there is now way to know exactly what.
      It is nothing but the same sample code that I found somewhere that is floating around to implement creation filters. Basically, the steps can be summed up as follows –
      – Create a class that Implements IUIElementCreationFilter
      – Implement both the interface methods namely BeforeCreateChildElements(UIElement parent) and AfterCreateChildElements(UIElement parent)
      – Just return false from the method BeforeCreateChildElements
      – Inside the AfterCreateChildElements method, call the get context method on the parent object to retrieve desired UIElement (HeaderUIElement in my case)
      – In my case, the UIElement is ExpansionIndicatorUIElement and I have implemented the property IsOpen, method InitAppearances and method Toggle respectively
      – The scheme of things works well so far, except the fact that when it loads for the second time, the InitalizeLayout is not fired and hence the filters disappear….working on it.
      • What do you mean by “Is there a way to fire InitializeLayout on purpose”? The event is fired when the grid is provided with a data source. If you want to call the code inside it multiple time, encapsulate the code inside the event in a method and then call the method.
      Ahh! I am assigning an empty UltraDataSource instance to the UltraGrid at design time in the InitializeComponent method itself. Also, contrary to what u said as to when the InitilializeLayout is called is at the time of datasource assignment does not hold ground here. For the first time, it gets fired on grid.Show() call. Next time the event is not triggered when the grid.Show method is called.

      Please let me know if you have any additional questions.

      As of now, I do have a lot of questions, but for now got to get a few implementations working….

      Thanks,

      Bhushan.

      • 0
        Dimitar
        Dimitar answered on Mar 12, 2016 10:03 AM

        Hi Bhushan,

         

        Thank you for posting in our forums.

         

        The InitializeLayout isn’t called on the Show method. In fact it is impossible to be called there, since the Show method is part of the Control class created by Microsoft and InitializeLayout event is defined on the UltraGrid class by us. In order to raise the event in the Show method we will need to override the Control method and this simply isn’t the case. It is called when the data source is provided or changed. 

         

        Anyway, it seems that there is something in your custom implementation that is causing the issues in your case. In order to assist you further on all this I would need a small sample that demonstrates this issue. Once I have the sample I will be glad to assist you further on this.

         

      • 0
        Bhushan Inamdar
        Bhushan Inamdar answered on Mar 12, 2016 7:37 PM

        Hi, 

           First of all many thanks to your explanations so far and suggestions; owing to them made me revisit the code and now I have resolved the issue. There are 2 cases here…

        [1] When the datasource is assigned in the designer by default, the grid and the datasource are empty i.e., without any schema as wellas data. In this case, as per my observation, the firing of the InitializeLayout is delayed till the point where Grid is shown. If there is no specific call to grid.show, then grid is is displayed by default on Form load event and is displayed once the method executes. Also, if there is a specific need to call the grid.show method as in the case of MVC implementation, the grid.Show becomes responsible for the showing of the grid and that is when the InitializeLayout is invoked. 

        [2] On the other hand, if we delay the datasource assignment and move it out of InitializeComponent() method of the designer, then as you have mentioned, the InitializeLayout event is fired when the datasource is assigned to the grid. And this is what I have done. I have kept the grids hidden in the designer's InitializeComponent() method and then in my custom method to show the grid, I have done the following…

        private void ShowInfragisticsGrid()

        {

        UltraGrid grid = null;

        UltraDataSource ds = null;

        switch(ultraTab.SelectedTab.Name)

        {

        case "tab1":

        grid = gridOnTab1;

        ds = dsForTab1;

        break;

        case "tab2":

        grid = gridOnTab2;

        ds = dsForTab2;

        break;

        case "tab3":

        grid = gridOnTab3;

        ds = dsForTab3;

        break;

        default:

        break;

        }

        grid.DataSource = null;

        m_HeaderArray = FetchColumnHeadersData(ultraTab.SelectedTab.Name);

        m_DataArray = PopulateDataStructure(ultraTab.SelectedTab.Name);

        PrepareUltraDataSourceColumns(ds);

        PrepareUltraGridColumns(grid);

        PopulateUltraDataSourceRows(ds);

        grid.Datasource = ds;

        //grid.Update();

        //grid.Invalidate();

        //grid.Refresh();

        grid.Visible = true;

        }

        I call this on the Tab Control's Tab Changed event and now it works fine. Assigning grid.Datasource to null before the processing and then reassigning the datasource back to the grid, makes the call to InitializeLayout and the logic for Creation Filters is thus invoked now. 

        [3] While looking through the code and working along, I have few more doubts in my mind over the calls to grid.Update(), grid.Invalidate(), grid.Refresh() and likewise. What is the difference between all these calls? I have read the documentation, however, I am not able to visualize the exact scenario where in each of these method calls serves a purpose. So if you could let me know as to when these calls be useful?

        [4] Also, I have some confusion over the use of grid.Show() / grid.Hide() versus grid.Visible = true / grid.Visible = false. What is the difference between the two cases and what scenarios which one to use?

        Thanks, 

        Bhushan. 

         

      • 0
        Dimitar
        Dimitar answered on Mar 14, 2016 10:45 AM

        Hi Bhushan,

         

        I am glad that your CreationFilter is working properly now.


        As for the difference between the Update, Invalidate and Refresh methods: The
        Invalidate method
        invalidates the whole control, making sure that it will be redrawn on the next paint message. The
        Update method
        forces a synchronous redraw of the control’s invalidated areas. The
        Refresh method
        invalidates the control and forces redrawing of the control. It is equal to first calling the Invalidate method and then calling the Update method immediately after that.

         

        There is no difference between grid.Show()/grid.Hide() and grid.Visible = true/grid.Visible = false. In fact what the methods do is that they set the Visible property to true or false.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Bhushan Inamdar
Favorites
0
Replies
5
Created On
Mar 14, 2016
Last Post
10 years, 6 months ago

Suggested Discussions

Tags

Created by

Created on

Mar 14, 2016 10:45 AM

Last activity on

Feb 23, 2026 5:31 PM