Hi ,
I have defined one XamGrid with ComboBoxColumn.
<ig:XamGrid x:Name="ManageRecipeStateGrid" AutoGenerateColumns="False" ColumnWidth="*" ItemsSource="{Binding ManageRecipeStateResults}">
<ig:XamGrid.GroupBySettings>
<ig:GroupBySettings AllowGroupByArea="Hidden" GroupByOperation="MergeCells" />
</ig:XamGrid.GroupBySettings>
<ig:XamGrid.Columns>
<ig:TextColumn Key="RecipeKey" Visibility="Collapsed" />
<ig:TextColumn Key="MandatoryCriteriaList" HeaderText="Recipe" IsReadOnly="True" >
</ig:TextColumn>
<ig:TextColumn Key="RecipeVersion" HeaderText="Version" IsReadOnly="True">
<ig:TextColumn Key="PreviousRecipeState" Visibility="Collapsed" />
<ig:ComboBoxColumn Width="120" HorizontalContentAlignment="Stretch"
ItemsSource="{Binding Source={StaticResource optionList}}" Key="CurrentRecipeState"
SelectedValuePath="State"
DisplayMemberPath="State"
AllowEditingValidation="True" HeaderText="Recipe State">
</ig:ComboBoxColumn>
<ig:CheckBoxColumn Key="IsPreserved" HeaderText="Preserve Recipe">
</ig:CheckBoxColumn>
</ig:XamGrid.Columns>
<ig:XamGrid.EditingSettings>
<ig:EditingSettings AllowEditing="Hover" />
</ig:XamGrid.EditingSettings>
</ig:XamGrid>
Now I want to handle the event whenever I change the item selection in ComboBoxColumn. How I can handle this ?
Hello,
Thank you for your post. I have been investigating how you can handle the selection changed event of the ComboBoxColumns and since the column is using a ComboBox as an editor when the cell is in edit mode, you can handle the SelectionChange event of the ComboBox. To do that, you can handle the CellEnteredEditMode event of the XamGrid and if the cell is of the ComboBoxColumn you can handle the SelectionChanged event. Here is an example for that:
private void ManageRecipeStateGrid_CellEnteredEditMode(object sender, Infragistics.Controls.Grids.EditingCellEventArgs e) { if (e.Cell.Column.Key.Equals("CurrentRecipeState")) { (e.Cell.Control.Content as ComboBox).SelectionChanged += new SelectionChangedEventHandler(MainWindow_SelectionChanged); } } void MainWindow_SelectionChanged(object sender, SelectionChangedEventArgs e) { //Do Something }
Another approach that you can use is creating a TemplteColumn instead of a ComboBoxColumn and in the EidorTemplate you can add a XamComboEdior and handle the SelectedItemChanged event. I have created a sample application for you, based on the code snippet that you have provide, which implements the mentioned approach.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hi,
How to select a selecteditem from combobox.
combobox.sleecteditem properties is not availablethen how we can store the sleecteditem to sql table?
can u give any idea?
thanks
I tried your solution. In my XamGrid I have this setting .
<ig:XamGrid.EditingSettings
>
<ig:EditingSettings AllowEditing
="Hover" />
</ig:XamGrid.EditingSettings
So after implementing your solution as soon as I hover on Preserve Recipe cell (where sate is State 2) I get this message which is correct but I dont want to pop up message on hover , I want to pop up message when I try to check the box.
One more thing I cannot change AllowEditing="Cell" because then it takes 3 clicks to check just a single check box. I have attached my modified solution with your solution implemented. Please check how we can handle this or is there any other way we can handle this scenario.
Thanks
Arpita
Hello Arpita,
Thank you for the clarification. I have been looking into the functionality that you are trying to achieve and I can suggest using the Click event of the CheckBox. You can handle the CellEnteredEditMode event of the XamGrid and there you can handle the Click event of e.Editor. Using the Click event of the Checkbox, you can get the Row that corresponds to the Cell and check the value of the CurrentRecipeState cell and show a message box. I have modified the sample application that I have previously sent, in order to implements this approach.
This works fine. One more thing if I select some state say State 1 and check the check the check box it works fine now I change to State 2 from drop down now this checkbox remains checked and if I try to uncheck it throws message. So to clear the checkbox selection if it is already checked and we change state to State 2 I implemented this piece of code in Selection item changed event but this doesnt seem to work . Can you please try this and let me know.
private void XamComboEditor_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object
> e)
{
// (sender as XamComboEditor).SelectedItemChanged -= XamComboEditor_SelectedItemChanged;
// DataRecord dr1 = ManageRecipeStateGrid.
Data activeRowData = (Utilities.GetAncestorFromType(sender as DependencyObject, typeof(CellControl), false) as CellControl).Cell.Row.Data as Data
;
List<Data
> tempAffectedRecipes = ManageRecipeStateResults;
if (activeRowData.CurrentRecipeState.Equals("State 2") && activeRowData.IsPreserved == true
)
// activeRowData.IsPreserved = false;
var query = from p in
tempAffectedRecipes
where
p.RecipeKey == activeRowData.RecipeKey
select
p;
foreach (Data tempDr in
query)
tempDr.IsPreserved =
false
}
ManageRecipeStateResults = tempAffectedRecipes;
ManageRecipeStateGrid.ItemsSource = ManageRecipeStateResults;
Thank you for your reply. I have been reading through it and if I understand correctly, your requirement is to uncheck the value of the Cell in Preserve Recipe column when the value of the combo column of the same row is “State 2”. If this is correct, I can suggest setting the Value of the Cell of Preserve Recipe column at the bottom of the SelectedItemChanged event of the XamComboEditor, if the SelectedItem of the XamComboEditor is “State 2”. I have modified the sample application that I have sent to you, with my previous email, in order to demonstrates how you can implement this approach.
Please let me know if this is what you are looking for, or I have misunderstood you in any way.
Thsi is fine. Can you please explain this SetCellValue function and why you have used this line
(e.Editor
as CheckBox).Click -= new RoutedEventHandler
(MainWindow_Click);
in CellExitingEditMode event.
Thank you for your reply. I am very glad that the approach I have suggested was helpful for you. Please let me know if you need any further assistance on the matter.
Hi Krasimir,
Thanks for the help. This works for me.
I am just checking if you require any further assistance on the matter.
Thank you for your reply. I am very glad that the approach I have suggested was helpful. I am using the SetCellValue method, since the Cell.Value property is read only and you can set the value of the cell, through the cell itself. This method is creating a CellValueObject which contains one dependency property and then creates a Binding between the property that corresponds to the current cell and the Value property of the CellValueObject, through the Data of the current row. After that, it sets the Value property of the CellValueObject, which triggers the Binding and this way the value of the property that corresponds to the cell is set, without interacting with the Data item of the current row.
Regarding the code that you have mentioned, in the CellExitingEditMode, I am de-attaching the handler, since each time the editor enters edit mode, a handler is attached to the Click event. If this code is commented, the hadnlers of the event will increase with one each time the Cell enters edit mode. This will case multiple execution of the the same function and when you enter ‘n’ times edit mode, for one cell and then click on the CheckBox, you will see that ‘n’ MessageBoxes are opened one after another.