Hi,
I need to create a custom control and use it as an editor to a grid column. Is there anyway I could achieve this?
Thanks.
What does your custom control need to do?
The best way to do something like this is to use one of the existing Editor controls.
If none of those meet your needs, and you are using the latest version of the controls (v9.2 or higher), then you can embed your own custom control in a grid using the new UltraControlContainer editor component.
Hi Mike,
Which editor are you referring to?
I'm using v9.2 and I can't embed my custom control in the grid because of the size.
Here's a shot of my custom control:
I need to show this editor when user click on a cell and apply text formatting (e.g.: color ) to the cell when they're done editing.
I got the dropdown working by embedding the EditorWithText and then add a DropDownEditorButton to it. How do I disable editing when the user click on the cell? I'd be better if I could active the dropdown control when clicking on the cell instead on the dropdown button.
Private Sub igGrid_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles igGrid.InitializeLayout
Dim ctrlEditor As New MyEditor
Dim txtEditor As New EditorWithText
Dim dropDown As New Infragistics.Win.UltraWinEditors.DropDownEditorButton
txtEditor.TextBox.ReadOnly = True
dropDown.Control = ctrlEditor
txtEditor.ButtonsRight.Add(dropDown)
e.Layout.Bands(0).Columns("Term").Editor = txtEditor
End Sub
When you said you wanted to embed the control in the cell, you didn't mention having a dropdown, so I thought you wanted your control right in the cell.
You won't be able to disable typing into the cell with an UltraTextEditor. What you have to do is set the Style on the column to DropDownList, but the UltraTextEditor won't know how to deal with this style, since it doesn't typically have a built-in list.
So what you can do is use an UltraComboEditor instead. You hide the built-in dropdown button on the combo by setting DropDownButtonDisplayStyle to Never. Then you add your DropDownEditorButton to the ButtonsRight collection, just like you did with the UltraTextEditor.
Assign the UltraComboEditor to the EditorControl property of the column and also set the Style on the Column to DropDownList.
At this point, whenever you click on the cell, it will automatically drop down the built-in list instead of your control, which is not what you want. But this is easily fixed by handling the grid's BeforeCellListDropDown event.This event lets you cancel the default dropdown list and then you can get the button from your editor and drop it down instead.
private void ultraGrid1_BeforeCellListDropDown(object sender, CancelableCellEventArgs e) { if (e.Cell.Column.Key == "String 1") { e.Cancel = true; EmbeddableEditorButtonBase editor = (EmbeddableEditorButtonBase)e.Cell.EditorResolved; DropDownEditorButton dropDownEditorButton = (DropDownEditorButton)editor.ButtonsRight[0]; dropDownEditorButton.DropDown(); } }
I got the dropdown working but now I can't display formatted text. How do I fix this?
There's no editor that will do both FormattedText and still behave as a DropDownList.
Maybe what you could do is use a FormattedTextEditor with a dropdown button, set the CellActivation on the column to not allow typing, and trap for clicks on the cell to drop it down manually. The user would still be able to select text in the cell, but that's about as close as you could get here, I think.