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,
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.
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.
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.
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.
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.