Hello,
I am using a EditorControl for a column in my ultragrid. The type of EditorControl I am using is UltraTextEditor and I added two StateEditorButtons to this control as depicted in the image I provided. The question that I have is that when you click one of the StateEditorButtons; making it checked value 'true', all cells in that column using the EditorControl StateEditorButton become checked as well, is there way to make this work only on the cell you clicked the StateEditorButton on? Please advise.
I attached the image so that you can see my dilemma when check state of the StateEditorButton changes for this column.
Adrian
I think whats happening here is that the grid is using the same copy of the editor for every cell in the column and there isn't anything that will store the individual state for each of the cells. To get around this, you will need an editor for each of the cells, though I think that creating an entirely new control isn't necessary and adds overhead. You could create a new editor in the InitializeRow event, i.e.:
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e){ if (e.Row.Cells["Col 1"].Editor == null) { EditorWithText editor = new EditorWithText(); editor.ButtonsRight.Add(new StateEditorButton()); e.Row.Cells["Col 1"].Editor = editor; }}
If you do want to set things up at design-time, you might be able to get away with:
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e){ if (e.Row.Cells["Col 1"].Editor == null) { EditorWithText editor = (EditorWithText)this.ultraTextEditor1.Editor.Clone(null); e.Row.Cells["Col 1"].Editor = editor; }}
-Matt
Hello Matt,
The second option seems to be working really well for me. Thanks alot!
Ok this clearing it up for some, however, I was looking on the editor for a 'Click' event but there is none. Am I looking in the wrong place?
I do understand how to get the ultragridcell from what you described though. Like this I am assuming.
UltraGridcell aCell = ((UltraGridCell)e.Row.Cells["Col 1"].Editor.ElementBeingEdited.GetContext());
I misspoke, I meant the Click event on the StateEditorButton. As for the GetContext, you'd likely have to pass in "typeof(UltraGridCell)" as well in order to get the cel.
Sorry for the late response. Perhaps I am not understanding how to get to the events on the StateEditorButton correctly, so I apologize for being a nuisance, but could you direct me as to how to get to the Click event programmatically. I did research the online documentation available and saw that the editor has events such as, BeforeEditorButtonCheckStateChanged and AfterEditorButtonCheckStateChanged available. Would those be of any use to me?
Click is on the base EmbeddableButtonBase class, so it will appear on the StateEditorButton too. But now that you mention it, I think that it would be better to hook the AfterEditorButtonCheckStateChanged events since at that point the buttons have been updated.
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e){ if (e.Row.Cells["Col 1"].Editor == null) { EditorWithText editor = (EditorWithText)this.ultraTextEditor1.Editor.Clone(null); StateEditorButton checkButton = (StateEditorButton)editor.ButtonsRight[0]; checkButton.AfterCheckStateChanged += new EditorButtonEventHandler(checkButton_AfterCheckStateChanged); e.Row.Cells["Col 1"].Editor = editor; }}void checkButton_AfterCheckStateChanged(object sender, EditorButtonEventArgs e){ // Handle the check logic}
This should help alot. Thanks again for all the help!