By using UltraControlContainerEditor i added my usercontrol (usercontrol has two radio buttons (Yes and No)) and paste it into the grid's particular cell. My code goes like this,
public void Initialize(LibertyGridProperties gridProperties, LibertyGridColumn[] columnDetails) {
case GridColumnStyle.UserControl: if (colData.UserControlProperties.Component == "CodeVsDesc") { colGridFormat[ultraGrid1.DisplayLayout.Bands[0].Columns[colData.UserControlProperties.ColumnName].Key] = GRID_EDIT_FORMAT.GRID_EDIT_OPTION; isEditable = true; } break;
}
void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) {
case GRID_EDIT_FORMAT.GRID_EDIT_OPTION:
Infragistics.Win.UltraWinEditors.UltraControlContainerEditor optionButtonsContainer; CodeVsDescription optionButtonsEditor; CodeVsDescription optionButtonsRender;
optionButtonsContainer = new Infragistics.Win.UltraWinEditors.UltraControlContainerEditor(); optionButtonsEditor = new CodeVsDescription(); optionButtonsRender = new CodeVsDescription();
optionButtonsEditor.Size = new System.Drawing.Size(139, 39); optionButtonsEditor.Visible = false; optionButtonsEditor.AutoSize = true; optionButtonsRender.Size = new System.Drawing.Size(49, 39); optionButtonsRender.Visible = false; optionButtonsRender.AutoSize = true; optionButtonsContainer.EditingControl = optionButtonsEditor; optionButtonsContainer.RenderingControl = optionButtonsRender; e.Row.Cells[key].EditorComponent = optionButtonsContainer; e.Row.Cells[key].Activation = Activation.AllowEdit; break;
Whenever i add rows dynamically into the grid , I can see the usercontrol into the particular column of the added rows. But I can select only one radio button at a time. For example, If i have 3 rows, I select Yes radio button in the first row and try to select No button in the second row of the user control. Once i select No on the 2nd row, first rows Yes selection becomes invalid and unselected automatically. I need to figure out the cause of this issue.
If i select any radio button , i should able to say to grid about the button and row that has been selected. Which event i should choose in this case. I feel personally that grid cell only knows about the container that it holds as it implements IProvidesEmbeddableEditor and dont know what control (my usercontrol with radio button)container holds. Because i have this.ultraGrid1.BeforeEnterEditMode += new CancelEventHandler(ultraGrid1_BeforeEnterEditMode); event and it fires when i click on the container not while clicking on any of theradio button. Please advise me.
Hi,
I'm having trouble understanding what you are asking here.
Are you saying that when you click on a radio button in row 2 that you want the radio button in row 1 to change?
Or are you saying that the radio button in row 1 is changing and you do not want that to happen?
The state of the radio buttons can only be determined by the value of the cell in the grid. I don't see anything in your sample code here that indicates what the data type of the grid column is. Nor do I see anything here that set the EditorControlPropertyName or the RenderingControlPropertyName. So I think the ControlContainerEditor is probably falling back to using the Text property of your UserControl and it doesn't seem likely that the Text property is what you want here.
Is it mandatory to set EditorControlPropertyName or the RenderingControlPropertyName and the data type of the grid column. Yes I am saying that the radio button in row 1 is changing and i do not want that to happen.
uthay said:Is it mandatory to set EditorControlPropertyName or the RenderingControlPropertyName and the data type of the grid column.
It's not always mandatory, but in this case, I'm pretty sure that if you do not explicitly set the data types and the property names that it will not work.
My guess is that the radio button in row 1 is not simply changing when you click on a cell in row 2, but that your control container editor is not set up properly to work with the column and so it is simply losing it's value any time the grid row is updated. If I am correct, then the same thing will happen if you click an option in any row of the grid and then click on any other row or on some control outside of the grid which takes focus, such as a button or a TextBox (but not a toolbar button).
In order for any of this to work properly, the grid has to know that something in the row changed. It does this by hooking events on the UltraControlContainerEditor based on the specified property. It probably falls back to the Text property by default, but checking an option in the OptionSet will not cause the Text to change and so the TextChanged event is not firing.
The UltraControlContainerEditor needs to know what property of the control it contains is being used to store/get the grid cell's value. And this property needs to match up with the DataType of the column.
So your CodeVsDescription needs top expose a single property that can get/set the current value (yes or no). And when that property changes, the control needs to fire event in the form of propertyNameChanged. Or you could implement INotifyPropertyChanged on your control.
And this property needs to be of a type that the grid column can store and re-store.
Hello Uthayaku,
For your reference, I have built a sample demonstrating the use of ControlContainerEditor with a User Control.
Please let me know if this helps you resolve the issue or if you have any further questions.
Hi Uthayakumar,
Were you able to add your user controls to the grid correctly? Please let me know if you require any further assistance.
Hi Mike,In the ControlContainerEditor C# samples attached , in SameRenderAndEditForm , whenever i move mouse between cells of AddressControl column , set event of Address property in AddressControl is fired.How is that set event related to mouse movement. How to avoid that.
Hello,
I will be happy to help you out with this issue.
I have created case # CAS82646-ZMHF6Q for you to better assist you with this issue going forward. To access the case, simply log into your IG account and click on My Support Activity.
Please let me know if you have further questions in this matter utilizing the case created.