Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Move ultragrid rows to the top of the grid

Move ultragrid rows to the top of the grid

New Discussion
Skankhunt P
Skankhunt P asked on Dec 5, 2016 11:21 AM

Hi,

I want to move a row to top of grid based on a condition.

I am iterating through the row collection of ultragrid and if a condition is met on a couple of column’s data, I want to move that row to the top of the grid.

I can’t leverage fixed-rows collection as my others data rows will be lost if I just show Fixedrows.

A couple more questions on Ultragrid are as follows:

1. How do we show the rich text editor on a column in ultragrid so user can enter his comments in Bold, italic etc.. A sample would be great

2. A Developer’s guide for Ultragrid would be great , like how to do basic stuff with Ultragrid, like grouping, Adding columns,Data Mapping etc.. Right now we have to search for every feature that we need to do with Ultragrid.

But a logical flow of How to’s would help us to quick start faster and easier.

Thanks,

Sign In to post a reply

Replies

  • 0
    Plamena Miteva
    Plamena Miteva answered on Oct 26, 2016 4:15 PM

    Hello Skankhunt,

    I have attached a sample windows forms project for your reference.

    I have created the MoveRowToTop method that is called when the button “Move Row To Top” is clicked. The method iterates over the grid’s rows collection and if a movie’s rating is equal to 10 places it at the top of the grid by setting its index to 0.

    You can enable a column’s formatted editing by embedding the WinFormattedTextEditor in a grid’s column. In the grid’s InitializeLayout event I have set up the WinFormattedTextEditor control and set it as the title column’s Editor. I have added the bold, italics, and underline items to the editor’s context menu. If you run the application, select some text from a cell in the title column and then click the mouse right button these menu items will be displayed. Clicking the respective items will apply that style to the selected text.

    You can find our developer’s guide and more detailed information about all our windows forms controls on http://www.infragistics.com/help/winforms.

    Looking forward to hear from you.

    • 0
      Skankhunt P
      Skankhunt P answered on Nov 23, 2016 12:01 AM

      Hi Plamena,

      I have a couple more questions on usage of Ultragrid.

      1. Can we group the rows of ultragrid row wise. Meaning. All the rows which have a specific value for a column will be displayed collapsed with a+ sign to the left of it indicating the presence of multiple rows in that group.

      2. Secondly, can we move these groups up and down the grid individually as a group or as a row? if so, a sample would be great.

      Thanks,

      • 0
        Plamena Miteva
        Plamena Miteva answered on Nov 24, 2016 1:50 PM

        Hello Skankhunt,

        1. Basically enabling the grid’s grouping allows you to group records of a band by a column. You can configure the grouping criteria by the GroupByMode property on the UltraGridColumn. I am not sure I understand what you mean by row wise. It would be great if you could give an example of what you are trying to achieve.

        2. You can allow the end-user to drag and drop rows or groups to a different location within the grid by setting its AllowDrop property to True and handling its drag and drop events. I have attached a sample project to demonstrate the above solution. The code allows end-user to move groups by selecting and dragging a group’s header. The SelectionDrag event fires when the end-user clicks and starts to drag a selected row. Then handle the DragOver event to set the drag effects and permit scrolling to occur so you can drag the row anywhere on the grid. Finally, in the DragDrop event get the position on the grid where the rows are to be dropped and move the selected rows to it.

      • 0
        Skankhunt P
        Skankhunt P answered on Nov 27, 2016 3:40 AM

        OK, let me clear out a bit.

        if a row has values A, B, C for Column 1 ,column2 and column 3 respectively. Similarly row 2 and 3 have (A,C,K),(BK,F) for columns 1,2,3 in that order.

        Now I meant to group row 1 and 2 by column1 as they have the same value for column1 and also want to show a '+' sign adjacent to that group indicating the presence of multiple rows in that group.

        Row 3 will be in a different group.

        Now, for the second part, I would like to move these groups programmatically up and down of the Grid based on certain criteria. So, I am just checking in if that is possible and easy.

      • 0
        Plamena Miteva
        Plamena Miteva answered on Nov 29, 2016 2:14 PM

        Hello Skankhunt,

        I think what you mean is grouping by column. You can enable grouping in code by setting the ViewStyleBand property of the grid’s DisplayLayout and adding the column you will group by to the Sorted Columns collection. I have done this in the attached sample project. When you run the sample all items will be grouped by the value in the Column1 column. As a result, two groups will be displayed: A containing 2 items (row 1 and 2) and B with 1 item (row 3). Each group has an expansion indicator and by default, the GroupBy rows can be expanded by either clicking on it, double-clicking on the GroupBy row, or with the keyboard.

        If the grid is grouped, then the UltraGrid.Rows will be a collection of GroupByRow rows and can be moved by the row Move method. In the attached sample I have added a ‘Move Group To Top’ Button. It moves the selected GroupByRow(s) to the top of the grid when clicked.

        UltraGridSample (1)

      • 0
        Skankhunt P
        Skankhunt P answered on Dec 2, 2016 12:08 AM

        Hi Plamena,

        when we group by a column the ordering that we did on the grid rows is lost. I want the grid to sustain the ordering that we did no matter what operation we does on the grid data. Is it possible?

        Can we handle the drag column event into the grouping area and reformat everytime..or any other elegant solution exists?

        Also, I want the first column in the current view of the grid to be fixed when I scroll horizonatally across the grid.

        Also, my grid has some empty/Blank rows, I want only the rows that has the data. Where can I set this.

        Thanks,

      • 0
        Plamena Miteva
        Plamena Miteva answered on Dec 5, 2016 11:21 AM

        Hello Skankhunt,

        1.You can handle the AfterSortChange event to detect grid’s ungrouping and move the rows up again in the event handler. AfterSortChange gets fired after the user sorts or groups rows by a column or when the user changes the sort direction of an already sorted column.

        2.To set a fixed column you should enable fixed headers for the grid first and then specify which column(s) in a specific band you want to remain fixed by setting the Fixed property of the associated Header object.

        this.ultraGrid1.DisplayLayout.UseFixedHeaders = true;
        this.ultraGrid1.DisplayLayout.Bands[0].Columns["MyColumn"].Header.Fixed = true;

        3.If by empty you mean that all of the values in all of the cells of a row are null you would have to loop through the grid's rows and then the cells in each row and check each cell individually. Then you can remove the row from the grid by the Delete method.
        this.ultraGrid1.Rows.[empty row index].Delete(false);

        If by empty you mean the rows after the last visible row in the grid, you can remove them by disabling the grid’s ShowEmptyRows feature.
        this.ultraGrid1.DisplayLayout.EmptyRowSettings.ShowEmptyRows = false;

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Skankhunt P
Favorites
0
Replies
7
Created On
Dec 05, 2016
Last Post
9 years, 10 months ago

Suggested Discussions

Tags

Created by

Created on

Dec 5, 2016 11:21 AM

Last activity on

Feb 25, 2026 7:39 AM