How can I Show MunericUpDown control as one of the editable columns in UltraGrid?
Please help on this.
Thanks,
Strictly speaking the answer to your question is to use the UltraControlContainerEditor to host a NumericUpDown control, and assign the UltraControlContainerEditor to the column's EditorComponent property.
Another approach is to use the column's masking and spin button capabilities to do it, like so:
UltraGridColumn column = e.Layout.Bands[x].Columns[y];column.MaskInput = "nnn";column.MinValue = 0;column.MaxValue = 999;column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.IntegerWithSpin;column.ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always;
It works. Thanks your great support.
Mike, I used the Editor as you suggested, but when I clicked the spin button, there is no change to the double and at the same time the spin button is disabled. Please give me some advice.
Hi,
Hm, this code worked fine for me. Is the column's DataType double?
Did you set a MaxValue or a MinValue on the column?
If you can post a small sample project of the behavior you are getting, I'd be happy to take a look, but I don't know why that's happening off the top of my head.
Attached is the code example. Please have a look.
thanks,
I took a look at your sample. It's not working because the DataType of your column is string. So there's no way the editor can do a numeric operation like adding 1 to the value, because it's not numeric.
Why are you storing numeric values as strings?
If you can, I would change it to a numeric type like Decimal or Double.
If you cannot, then you would have to use an EditorSpinButton and handle the Spin events yourself and modify the value in code.
Yes, you are correct. It works after I change the type to float. Is there a property to hide the underline in the editor?
Thank you very match.
I don't even have v6.2 any more, so I'm not absolutely sure. But I think you cannot use an editor in that case, you will need an Editor Control.
So what you would do is put an UltraMaskedEdit control on the form and set the EditorControl property of the column to that UltraMaskedEditor control.
Then you handle the EditorSpinButtonClick event of the UltraMaskedEdit control.
Here's some sample code. But frankly, this code isn't really that great. I would put the UltraMaskedEdit control on the form and set it's properties in the designer instead of using the InitializeLayout event. It's just cleaner.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridOverride ov = layout.Override; UltraGridColumn column = band.Columns["Double 1"]; column.Header.VisiblePosition = 1; column.MaskInput = "nnn.n"; column.MinValue = 0.0; column.MaxValue = 999.9; UltraMaskedEdit ultraMaskedEdit = new UltraMaskedEdit(); this.Controls.Add(ultraMaskedEdit); ultraMaskedEdit.EditorSpinButtonClick += new Infragistics.Win.UltraWinEditors.SpinButtonClickEventHandler(ultraMaskedEdit_EditorSpinButtonClick); ultraMaskedEdit.ButtonsRight.Add(new SpinEditorButton()); column.EditorControl = ultraMaskedEdit; column.ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always; } void ultraMaskedEdit_EditorSpinButtonClick(object sender, Infragistics.Win.UltraWinEditors.SpinButtonClickEventArgs e) { UltraGridCell cell = e.Context as UltraGridCell; switch (e.ButtonType) { case Infragistics.Win.UltraWinEditors.SpinButtonItem.NextItem: cell.Value = (double)cell.Value + 0.1; break; case Infragistics.Win.UltraWinEditors.SpinButtonItem.PreviousItem: cell.Value = (double)cell.Value - 0.1; break; } }
Thank you Mike for your response.
I use Infragistics v6.2, but i not able to upgrade controls. Who is the spin event when i can increment value on 1.0
Please help me.
If the SpinIncrement property does not exist, then you are probably using a very old version of the controls from before that feature was added. The solution would be to update to a new version or handled the spin button events and increment the value yourself.
I try your code but
editorWithMask.SpinIncrement not exist
Pleas help me.