Hi,
I need some functionality to be able to show some related data in a single row in the data grid. For that I planned to show a data grid in a cell of the grid.
For example below are my classes:
class A
{
public string A1;
public string A2;
public string A3;
public List<B> A4;
}
class B
public string B1;
public string B2;
public string B3;
class A with fields A1,A2,A3 & A4 ; another class B with fields B1, B2 & B3.
B1 is the primary key in B with A1 as its foreign key.
I need to show the data for each object of A in a single row including data of field A4 (type is B). So, in the grid I am expecting columns A1,A2,A3 & A4. I planned A4 to show as a combo and that combo will have a grid to show all the data for that field.
1. Is that possible to show a combo for a field in data grid?
2. Is that possible to attach a data grid to that combo box so that to display all the fields of that complex fields in the sub grid?
3. After achieving the above two points I have to ensure that user can select that combo box and change the pair of selected rows from the sub-grid. Also, the user should be able to select the complete row. So, is that possible to have row as well as cell selection (for some specific cells)?
PS: I am using Ultra Win Grid in a windows application.
Thanks in Advance for the help.
Hello Nitin,
There are different approaches to solve this task depending of your requirements. I made small sample for you with one possible approach. Could you please take a look at the attached smple for more details and let me know if you have any question.
Regards
Here is the sample
Nitin Jain said:The only thing left is to make the cell non-editable after selecting the data from the sub-grid.
Maybe one possible approach to acheive this behavior could be if you handle ultraGrid1_InitializeRow() event. For example:
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
if (e.Row.Cells["SelectedChild"].Value != null)
e.Row.Cells["SelectedChild"].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
}}
Please take a look at the modification that I made into our sample. Also my suggestion is to use RowSelect. You will get approx the same behavior for the end users.
Let me know if you have any questions
Hi Georgi,
May be I was not clear on the requirement.
What I want is to have a combo box with a list of items on a data grid cell, but the user can only change the value of that cell by selecting a value in the sub-grid not using keyboard.
So far, I managed to implement the combo with the data grid and able to set the selected value in the sub grid into the cell.
But, the user can change the value using keyboard also, which I do not want.
I want to have something like a combo box with a drop down from which user can select value but can not change it freehand.
Regards,
Nitin Jain
If I understand well your requirement, you could set property:
ultraCombo1.DropDownStyle = Infragistics.Win.UltraWinGrid.UltraComboStyle.DropDownList;
Please let me know if you think that I misunderstand your questions or if you have any further questions.
I have already set DropDownStyle to DropDownList, but still the cell to which combo box is attached is coming as editable when I am clicking on drop down button and after selecting the value from the sub-grid.
Hello Nitin,Did you try to set the columns Style property to 'DropDownList' and test this out again?
Hi Boris,
That is awesome. This is exactly what I need from decorative point of view.
Thanks for the reply.
You could achieve this using the following code in the 'BeforeCellListDropdown' event:
ultraCombo1.DisplayLayout.Bands[0].Columns[1].Hidden = true; ultraCombo1.DisplayLayout.Bands[0].Columns[0].Header.Caption = "Custom";
Please feel free to let me know if a question about our tool set comes up on your mind.
Is there any way by which we can show certain columns and hide some when popping up the sub-grid in combo-box?
Also, Is it possible to change the display name of the columns in sub-grid?
Thanks Boris,
This is exactly what I need. Actually by mistake (or by lack of knowledge) I set Cell's Style property to DropDown, which I guess was incorrect in both the manners.
But now after setting up columns style property I am getting a non-editable drop down control, that I needed.
Many Thanks to both of you for all the help provided.
Could you please review the sample attached to this post and see if it meets your requirements.Please feel free to let me know if I misunderstood you or if you have any other questions.