Is it possible to set row numbering for the RowSelector? (e.g. I want to start numbering with 101 instead of 1)
Hi,
There's nothing built-in to allow you to do this, but there are a couple of ways you could acheive what you want.
The easiest way, in my opinion would be to use a CreationFilter. You could then change the text of the TextUIElement in the row selector for each row.
I followed an example from your website and was able to get this to work -- I have a column called "Index" and the value in this column corresponding to the row is the value I display in the row selector. This is all working, but I'm experiencing a couple of issues.
First issue is that I also am using fixed row selectors (the little push pin). I can still see the push pin in the row selector, but it no longer works. Clicking on the pushpin does nothing other than highlight the row.
Second issue is the little triangle indicating the active row. The triangle is drawn in the middle of the row selector area, directly on top of the text rendered from the creation filter. I would like for the triangle to be drawn at right of the text, just as it does prior to my adding the creation filter.
Any ideas how to solve these issues?
Thanks in advance for your help.
-- Julie
jnyikos said:I copied most of the code straight out of the example downloaded from the Infragistics knowledge base called editor_row_selector_header_cs.zip
This article doesn't really seem to be related to what you want to do. In fact, it's quite a bit more complicated than you need for the task at hand.You don't need to create a TextUIElement inside the RowSelector. What I would do is turn on the RowSelectorNumbers. This will make the grid create a TextUIElement for you and position it so that it's in the right place with respect to the ActiveRow arrow indicator and the Fixed row button. Then all you have to do is change the text.
jnyikos said:except in the CreationFilter, I moved the code that was in BeforeCreateChildElements to AfterCreateChildElements because it needed to access to values in the table which isn't available until "After".
You certainly can get a value from a cell in the row inside the Before event. But in this case, you really want to use the After, anyway, so that you can set the Text on the element aftet the grid has already created it.
So the CreationFilter looks something like this:
public void AfterCreateChildElements(UIElement parent) { // Trap for a TextUIElement TextUIElement textUIElement = parent as TextUIElement; if (textUIElement == null) return; // Make sure the element is the child of the RowSelectorUIElement UIElement rowSelectorUIElement = parent.GetAncestor(typeof(RowSelectorUIElement)) as RowSelectorUIElement; if (rowSelectorUIElement == null) return; // We now know that the parent is a TextUIElement which is inside a RowSelectorUIElement. // Now all we have to do is set the text. UltraGridRow row = parent.GetContext(typeof(UltraGridRow)) as UltraGridRow; textUIElement.Text = row.Cells["Name"].Text; } public bool BeforeCreateChildElements(UIElement parent) { // We do not want to do anything before the child elements of the column header are created, so just return false. return false; }
You will probably also want to set the RowSelectorWidth on the grid's Override so that there is plenty of room for the text.
I copied most of the code straight out of the example downloaded from the Infragistics knowledge base called editor_row_selector_header_cs.zip -- except in the CreationFilter, I moved the code that was in BeforeCreateChildElements to AfterCreateChildElements because it needed to access to values in the table which isn't available until "After".
private void myGrid_InitializeLayout(object sender, InitializeLayoutEventArgs e) { myGrid.CreationFilter = new NumbersInRowSelectors(); e.Layout.Override.FixedRowIndicator = FixedRowIndicator.Button; }
//The NumbersInRowSelectors class. This class Implements a CreationFilter and //adds a TextUIElement to each RowSelector which displays the row number of //the row. public class NumbersInRowSelectors : Infragistics.Win.IUIElementCreationFilter {
#region Implementation of IUIElementCreationFilter public void AfterCreateChildElements(Infragistics.Win.UIElement parent) { //Declare some variables Infragistics.Win.TextUIElement objTextUIElement; Infragistics.Win.UltraWinGrid.RowSelectorUIElement objRowSelectorUIElement; Infragistics.Win.UltraWinGrid.UltraGridRow objRow; int RowNumber;
//Check to see if the parent is a RowSelectorUIElement. If not, //we don't need to do anything if (parent is Infragistics.Win.UltraWinGrid.RowSelectorUIElement) { //Get the Row from the RowSelectorsUIElement objRowSelectorUIElement = (Infragistics.Win.UltraWinGrid.RowSelectorUIElement)parent; objRow = (Infragistics.Win.UltraWinGrid.UltraGridRow)objRowSelectorUIElement.GetContext(typeof(Infragistics.Win.UltraWinGrid.UltraGridRow));
//Use the value from the "Index" column to put as the RowNumber in the Row Selector Object obj = objRow.Cells["Index"].Value; RowNumber = System.Convert.ToInt32(obj);
//Check to see if the TextUIElement is already created. Since //The RowSelectorsUIElement never has children by default, we //can just check the count. if (parent.ChildElements.Count <= 1) //Fixed Indicator is always one of the elements { //Create a new TextUIElement and parent it to the RowSelectorUIElement objTextUIElement = new Infragistics.Win.TextUIElement(parent, RowNumber.ToString()); parent.ChildElements.Add(objTextUIElement); } else { //There's already a TextUIElement here, so just set the Text objTextUIElement = (Infragistics.Win.TextUIElement)parent.ChildElements[0]; objTextUIElement.Text = RowNumber.ToString(); } //Position the TextUIElement into the RowSelectorUIElement objTextUIElement.Rect = parent.RectInsideBorders; } } public bool BeforeCreateChildElements(Infragistics.Win.UIElement parent) { return false; } #endregion }
Hi Julie,
Without knowing what your CreationFilter is doing, it's impossible to say what's happening here.
Can you post a small sample project demonstrating these issues?