Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
I am already able to build a context menu for the checkbox cells in Grid_PreviewMouseRightButtonDown.
Now when the user has selected a range of cells and right clicks, I wish to iterate the cells and build a context menu that is filled with the combo items for the selected cells only if the selected cells are of the same combo type (meaning they contain all the same strings as choices in the combo). So then the user can select a context menu item and set all the selected combos to that value.
I don’t know how to get at the combo items collection for the selected cells to populate my context menu and test for more than one combo type being selected.
If there is a better way to create the context menu I am open to suggestions.
The selected cells you can access through the SelectedItems.Cells collection. You can iterate through that collection and get their values.
Thanks for your reply.
The issue I am having is I am trying to get at the ComboBoxDataItem from code behind so I can see if the selected cells are all combos with the same ComboBoxDataItem items in them so that I can create a context menu from/with this list of choices and also I don’t want to display the context menu if the user has selected cells where they are not all of the same ComboBoxDataItem. I tried looking in the watch window and I could not find the ComboBoxDataItem given the cell.
<igEditors:ComboBoxItemsProvider x:Key="comboItems">
<igEditors:ComboBoxItemsProvider.Items>
<igEditors:ComboBoxDataItem DisplayText="Item1" Value="0" />
<igEditors:ComboBoxDataItem DisplayText="Item2" Value="1" />
</igEditors:ComboBoxItemsProvider.Items>
</igEditors:ComboBoxItemsProvider>
This is already working fine for checkboxes:
private void Grid_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
// verify that all fields are of type checkbox
foreach(Infragistics.Windows.DataPresenter.Cell myCell in xamDataGrid1.SelectedItems.Cells)
// myCell.Record.DataItem
if (myCell.Field.DataType == typeof(bool))