I am having ultragrid just like properties window. ie, each row has different controls on it like
1st row -> UltraCheckEditor
2nd row -> combo box
3rd row -> default text editor (which is supported by UltraGrid in edit mode)
I would like to make the 3rd row default text editor control to accept only signed integers. How can i achieve this functionality ? ONLY for CELL... not for Column...
Through columstyle , in my datagrid i am displaying integer but if i want integer like ranges for example: 12-15, 30-38.
What i need to do.
Please Help me and thanks in advance
Hi,
Getting that kind of fine control over an individual cell will be very tricky.
1) There's no way to remove the prompt character for a masked editor. You could change it to a 'space' character, but you will have to do this for the whole column.
2) The property you want is not SelLength (which is the length of the current selection) but MaxLength. There is no way to set MaxLength on an individual cell, it can only be set on the column. But in this case, you don't need to set it, anyway, because you can simply set the editor's mask to only permit three places.
Here's some quick sample code I threw together just to show you how to do this. This code is not very efficient, since I am creating a new editor every time InitializeRow fires. For your real code, you should cache and re-use the same editor for the same cell and any other cell who's requirements are the same.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; band.Columns["Column 0"].PromptChar = ' '; } private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { if (e.Row.Index == 2) { // Note that this code is very inefficient. I am creating a new editor for the cell // every time this event fires. The editor should be cached and re-used for any // cell in the grid with the same requirements. // e.Row.Cells["Column 0"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Integer; DefaultEditorOwnerSettings defaultEditorOwnerSettings = new DefaultEditorOwnerSettings(); defaultEditorOwnerSettings.MaskInput = "nnn"; DefaultEditorOwner defaultEditorOwner = new DefaultEditorOwner(defaultEditorOwnerSettings); EditorWithMask editorWithMask = new EditorWithMask(defaultEditorOwner); e.Row.Cells["Column 0"].Editor = editorWithMask; } }
Thank you mike. kindly help me find the below details also.
1. How can i remove the "_" character from the Row.
2. How can I limit the number of characters in the cell to "3". Tried SelLength = 3; but its throwing a run time exception.
Please note that all the row consists of different controls like a property grid.
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.Index == 2) e.Row.Cells["My Column"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Integer; }
Hi Mike,
Thank you for the reply. But how can i achieve
"3rd row default text editor control to accept only integers". Text editor control which accepts only integer values.