Hi,
I want to add my custom UltraComboEditor in Ultrawingrid. i implemented as mentioned below.
MyUltraComboEditor myComboEditor = new MyUltraComboEditor();myComboEditor.DropDownStyle = DropDownStyle.DropDownList;
//..Getting Values and adding into the list ..
libertyComboEditor.Items.Add(new ValueListItem(kv[0], kv[1]));
ultraGrid1.DisplayLayout.Bands[0].Columns[j].EditorControl = myComboEditor;
Here, i set the DropDownStyle to DropDownList but still the cell is editable.
Moreover, I want to set the Combo value at the runtime. But i wont be able to achieve this.
public void SetComboValue(int rowno, string key, int band, string value){UltraGridRow row = this.ultraGrid1.Rows[rowno];if (row != null){UltraGridCell cell;cell = row.Cells[this.ultraGrid1.DisplayLayout.Bands[band].Columns[key]];MyUltraComboEditor myComboEditor = (MyUltraComboEditor)cell.EditorControlResolved;int t = 0;t = myComboEditor.FindString(value);myComboEditor.SelectedIndex = t;}}
I want to capture the ValueChanged event. Even that is not firing.
will anyone help me on this.
Thanks,
In this case, you should be relying more on the properties of the grid itself, not the editor. Try setting the Style on the column to DropDownList and see if that addresses your issue. As for setting the combo value on the control itself, I don't think this is going to work either since the grid column uses a clone of the editor that the control uses; the EditorControlResolved/EditorResolved properties will, in this case, return the same instance for all cells in the column, so you would be modifying them for the entire column anyway. I think that your best bet would be to set the Value of the cell directly instead.
-Matt
Thanks for the reply,
i want to expose my own properties and methods for combo box in the Ultrawingrid (say, method to cache combo values of the column) and i want to capture the event of ItemChanged to do some validations. For that reason, i have created a custom combo editor and i expose my own properties and methods. But if i set the column style to Dropdown list will i be able to acieve all the below mentioned things?
1. Capture the selecteditem change event?
2. How to change the Selected Item of the combo box at the the runtime?
3. How to change the list item at the runtime?
I'm not sure that the various events of the combo will fire when used in the grid, since the grid is now the owner of the editor that is provided by the combo.
1) If this event isn't firing on the combo, you might want to look at the AfterCellListCloseUp or TextChanged events of the grid.
2) As I mentioned in my previous post, you would need to set the value of the cell directly. If you want to get at the actual editor, you might be able to set it directly on the ValueList:
((ValueList)((EditorWithCombo)this.ultraGrid1.ActiveCell.EditorResolved).ValueList).SelectedItem = something;
3) I'm not sure what you mean here. If you want to change a specific item in the ValueList just for one cell (and not all cells in the column), you would need to have a unique ValueList/editor on that cell and either manipulate the ValueList, or possibly update the relevant properties on the control itself (though I'm not quite sure if this approach will work after you've assigned the EditorControl of the cell/column).
Matt,
Thanks for the reply. I tried implementing as like what you have posted but i have few questions .
I set the UltraComboEditor to the EditorControl property of Ultrawingrid with some predefined listitems for the column as mentioned below.
ultraGrid1.DisplayLayout.Bands[0].Columns["Combo"].EditorControl = ComboEditor
I set the datatable to the datasouce property of Ultrawingrid. Based on the values in the datatable the specific item will get selected in each cell in the column. Upto here i don have any issue. Now as i mentioned earlier i want to change the list item of specific cell and it should not affect the entire column. How to do that?
Or how to set the cellListItem / Editor at the design time. That is, i need to say somewhere that, new editor's instance should be created for each cell instead "ultraGrid1.DisplayLayout.Bands[0].Columns["Combo"].EditorControl = ComboEditor".
Hope you get my requirement
Thanks
Try setting the Activation to ActivateOnly. That settings allows the user to click on the cell and enter edit mode, but not to change the value.
Mike,
Thanks for the reply.
I have Column A (Items: "Buy","Redeem" and "Exchange") and Column B (Items: "Empty", "Yes", "No" )and i have List items in both the columns as specified.
By Default While loading grid, Buy is selected in Column A and "Empty" is selected in Column B
On Before Enter Mode event, based on the selection of cells in Column A i want to Enable OR Disable the UltraComboEditor in Column B
(So in this case, as you mentioned i can use CellActivation.NoEdit OR Activation.AllowEdit;) void ultraGrid1_BeforeEnterEditMode(object sender, System.ComponentModel.CancelEventArgs e) { if (ultraGrid1.ActiveRow.Cells[1].Value.ToString() != "Buy") ultraGrid1.ActiveRow.Cells[5].Activation = Activation.NoEdit; else ultraGrid1.ActiveRow.Cells[5].Activation = Activation.AllowEdit; }
void ultraGrid1_AfterExitEditMode(object sender, System.EventArgs e) { //do some other validation and set the value for some other cells. }
Now, For the first time, i click on Column A and On before Enter edit mode, nothing will happen since i have the check to "Buy".now i select Redeem, and then i click on Column B, not the cell becomes non editable.
since the cell becomes non editable, Column B is not entering into Edit mode.
My requirement is this: The Cell (Column B) should always be in edit mode. But the Controls (Controls i mean, the UltraComboEditor) inside that can be Enabled or Disabled.Is there any way to do this?
Thanks.
RMuthu said:i want to disable the UltraComboeditor in few cells
What exactly do you mean by this? If you don't want a dropdown in some cells, then simply do not set the EditorControl on that cell.Or, you could use the Activation property on the cell to disable editing of that cell.
Disabling the ComboEditor control will not have any effect on the grid. The grid doesn't really use the control, the control provides an editor for use by the grid.
I add UltraComboEditor in the InitializeRow event so that i can assign Ultracomboeditor for each row.
Now i want to disable the UltraComboeditor in few cells. but its not working. Please let me know how to do that.
Please find the code below
public void EnableCombo(int row, string columnKey, boo enable)
{
if (0 <= row && row < ultraGrid1.Rows.Count)
if
(mColumnProperties.ContainsKey(columnKey))
UltraComboEditor myComboEditor = new UltraComboEditor();
myComboEditor = (
UltraComboEditor)ultraGrid1.Rows[row].Cells[columnKey].EditorControlResolved;
if (myComboEditor != null)
myComboEditor.Enabled = enable;
}
You cannot tell the grid at design-time that it needs to create a *new* editor for each row, so you would have to use the InitializeRow event to assign a new instance yourself. As I mentioned in my previous posts, if you want to modify the list in a particular cell without having the list in the entire column affected, you need to have a new editor on that cell with its own list; if you only need to select a new value, you can assign the value of the cell, as I mentioned.