devexpress gridcontrol multiselect - multi-select

I know that multiple selection can be done is via the property SelectionMode = "MultipleRow" but it is very simple to my need. Do you know any property that enable to extend this functionality to use the keys like Shift and Control for a more rich/intuitive use of multiple selection in the GridControl.

I found it. just use MultiSelectMode="Cell"
<dxg:GridControl
x:Name="MyGrid"
ItemsSource="{Binding Path=MyList}"
ShowBorder="False"
AutoGenerateColumns="AddNew"
MaxHeight="10000"
ClipboardCopyMode="ExcludeHeader"
ShowLoadingPanel="{Binding IsBusy, Mode=OneWay, FallbackValue=true}">
<dxg:GridControl.View>
<dxg:TableView AllowEditing="False"
MultiSelectMode="Cell"/>
</dxg:GridControl.View>
</dxg:GridControl>
</dxd:DocumentPanel
>

Related

Using a DevX LookUpEdit control, with a GridControl, how can I hide column headings?

I currently have the following DevExpress WPF LookUpEdit control in my Xaml file. For the life of me, I can't find a way to hide the header row on the internal grid control. I'd like a very basic, single-column Tree View control. How can this be done?
<dxg:LookUpEdit x:Name="hierarchy"
Grid.Column="3"
Grid.Row="1"
HorizontalAlignment="Left"
Height="22"
Width="120"
Margin="0,2,0,3"
VerticalAlignment="Center"
FilterCondition="Contains"
ImmediatePopup="True"
ValueMember="nodeName"
DisplayMember="description"
EditValue="{Binding nodeName}"
ItemsSource="{Binding Source={StaticResource nodesSrc}}"
AutoPopulateColumns="False">
<dxg:LookUpEdit.PopupContentTemplate>
<ControlTemplate>
<dxg:GridControl >
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="description" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TreeListView
AutoWidth="True"
KeyFieldName="id"
ParentFieldName="parentID"
TreeDerivationMode="Selfreference">
</dxg:TreeListView>
</dxg:GridControl.View>
</dxg:GridControl>
</ControlTemplate>
</dxg:LookUpEdit.PopupContentTemplate>
</dxg:LookUpEdit>
Please, take a look at the Column Header Panel help-article - you can control this panel's visibility via the TreeListView.ShowColumnHeaders property.
P.S. Further, I suggest you to use the Visual Elements documentation-section that describe the control elements that you see on screen. Each sub-topic of this section contains a screenshot that outlines the described element and a brief overview of the element's purpose. Additionally, each topic contains a list of the settings that specify the element's visibility, content and appearance.

How can I specify visible columns on a GridControl?

I have bound a collection from my database to a DevX GridControl.
By default, it is shows all columns. How can I modify my Xaml code to strictly show the columns that I specify?
Here is the Xaml code:
<dxg:GridControl x:Name="lst1" AutoGenerateColumns="AddNew" ItemsSource="{Binding ListaImpianti}" ColumnsSource="{Binding c}"
EnableSmartColumnsGeneration="True" HorizontalAlignment="Left" Margin="93,131,0,0" VerticalAlignment="Top" Width="346"
FilterCriteria="{Binding FilterCriteria, ElementName=searchControl}" Height="479" >
<dxg:GridControl.Columns>
<dxg:GridColumn x:Name="CODICE" Binding="{Binding CODICE}" FieldName="CODICE"/>
<dxg:GridColumn x:Name="NOME" Binding="{Binding NOME}" FieldName="NOME"/>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowPerPixelScrolling="True" ShowTotalSummary="True" AllowEditing="False" ShowGroupPanel="False" />
</dxg:GridControl.View>
</dxg:GridControl>
ListaImpianti is the query result from the ViewModel. It contains numerous fields and I would like to only show the fields NOME and CODICE.
SOLUTION: remove AutoGenerateColumns="AddNew".
I ran into this problem, however, I was using a GridControl from within a ControlTemplate that was embedded within a LookUpEdit control. I found it rather frustrating since no option within the AutoGenerateColumns had any effect. After a bit of further digging, I found that the LookUpEdit control has a property called AutoPopulateColumns which overrides this value. The property is a boolean and setting it to False will allow you to manually define your own columns.

How bind data from multiple datasource field in a single gridcontrol cell

I'm a beginner with WPF. I need to show two textblock in a single gridcontrol cell and bind them to a different fields from data source. The first step is clear for me. But I can't understand how I should bind Text property of TextBlock to datasource properies.
Please, give me some notes and advices.
Below some code (xaml) lines. So I need to show in the first TextBlock property ProjectPriority and in the second - ProjectDeadLine.
That's my datasource
<dx:LinqCollectionViewDataSource x:Key="LinqCollectionViewDataSource" Culture="ru" ContextType="{x:Type ORM:FPMDataContext}" CollectionViewType="{x:Type ListCollectionView}" dx:DesignDataManager.DesignData="{dx:DesignDataSettings RowCount=5, UseDistinctValues=True}" Path="ActualProjectView">
<dx:LinqCollectionViewDataSource.SortDescriptions>
<ComponentModel:SortDescription Direction="Ascending" PropertyName="ProjectDeadlineDate"/>
<ComponentModel:SortDescription Direction="Descending" PropertyName="ProjectPriority"/>
<ComponentModel:SortDescription Direction="Descending" PropertyName="ProjectCreationDate"/>
</dx:LinqCollectionViewDataSource.SortDescriptions>
</dx:LinqCollectionViewDataSource>
And that's GridControl:
<dxg:GridControl AutoPopulateColumns="True" ItemsSource="{Binding Data, Source={StaticResource LinqCollectionViewDataSource}}" Margin="0,-10,0,10">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="ProjectPriority" >
<dxg:GridColumn.DisplayTemplate>
<ControlTemplate>
<StackPanel>
<TextBlock Text="{Binding ProjectPriority}"/>
<TextBlock Text="{Binding ProjectDeadLine}"/>
</StackPanel>
</ControlTemplate>
</dxg:GridColumn.DisplayTemplate>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView ShowTotalSummary="True" ShowAutoFilterRow="True" FocusedViewChanged="TableView_FocusedViewChanged"/>
</dxg:GridControl.View>
</dxg:GridControl>
With a ItemsControl like a GridControl your Itemssource is a Collection of Type T. Inside your Column you can access the Properties of class T via Binding.
It seems you have a Collection called Data. The Framework will look for the ProjectPriority Property in each Entry of this List.

Devexpress ComboBoxEditSettings not binding to ViewModel in WPF

I'm having a problem with the DevExpress wpf grid binding when using the ComboBoxEditSettings. Below is the grid. I'm binding the "Associated Well Types" column to a property on my ViewModel. However, when I select some items from the combo box and then click "Ok", I see the selected items in the cell, but they don't bind back to my ViewModel. So, do I need to do something with the "Ok" button's click event? Is there
something in the binding that I'm not setting up properly? All of the above?
Thanks in advance for your help.
<ctrls:GridControl Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Margin="5"
dx:ThemeManager.ThemeName="Office2007Blue"
x:Name="gridControlForms" VerticalAlignment="Stretch"
ShowLoadingPanel="{Binding TaxFormsIsBusy}"
ItemsSource="{Binding TaxFormList}" >
<ctrls:GridControl.Columns>
<dxg:GridColumn FieldName="DisplayName" Header="Form Name" VisibleIndex="1" AllowMoving="False" />
<dxg:GridColumn ReadOnly="True" FieldName="PrintSequence" Header="Print Sequence" VisibleIndex="2" AllowMoving="False" />
<dxg:GridColumn Header="Associated Well Types" FieldName="SelectedWellTypes" VisibleIndex="3" AllowMoving="False" AllowBestFit="True" Width="300" >
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding WellTypes}" DisplayMember="WellType" ValueMember="RenditionStateFormWellTypeId" IsTextEditable="False" >
<dxe:ComboBoxEditSettings.StyleSettings>
<dxe:CheckedComboBoxStyleSettings />
</dxe:ComboBoxEditSettings.StyleSettings>
</dxe:ComboBoxEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</ctrls:GridControl.Columns>
<ctrls:GridControl.View>
<dxg:TableView ShowGroupPanel="False" BestFitArea="All" AllowSorting="False"
FocusedRow="{Binding SelectedTaxForm, Mode=TwoWay}" AllowColumnFiltering="False" />
</ctrls:GridControl.View>
I discovered the problem: the grid was throwing an "Object must implement IConvertible" error. Once I discovered that, I changed SelectedWellTypes from an int to a IEnumberable of type object and did the appropriate conversions in the viewmodel. This allowed the binding to occur.

How to close the DevExpress WPF ComboBox when the Row of a Nested Grid is selected?

I am using DevExpress WPF controls, expessicaly the BarEditItem, ComboBoxEdit and GridControl.
Normally when you use the standard ComboBoxEdit, when you select an item, the combobox closed.
However, I am now setting the ComboBoxEditSettings.PopupContentTemplate to a GridControl.
Whenever I select a row in the GridControl (by clicking on it), I want the dropdown to close.
It works when I hit the key, but not when I simply click a record.
The XAML looks like this:
<dxb:BarEditItem.EditSettings >
<dxe:ComboBoxEditSettings
ItemsSource="{Binding Path=EditieCollection}"
DisplayMember="JaarEditieNummer"
AutoComplete="True"
Name="editieComboBox" AcceptsReturn="True" IncrementalFiltering="False" ImmediatePopup="True">
<dxe:ComboBoxEditSettings.PopupContentTemplate >
<ControlTemplate>
<dxg:GridControl
Name="PART_GridControl"
ItemsSource="{Binding Path=EditieCollection}"
AutoPopulateColumns="False" ShowBorder="False"
>
<dxg:GridControl.Columns>
<dxg:GridColumn x:Name="EditieJaarEditieNummer" FieldName="JaarEditieNummer" Header="Editie" Width="90" />
<dxg:GridColumn x:Name="EditieOplage" FieldName="OplageDatum" Header="Oplage" Width="90" />
<dxg:GridColumn x:Name="EditieVerschijning" FieldName="Datum" Header="Verschijnt" Width="90" />
<dxg:GridColumn x:Name="EditieOmschrijving" FieldName="Omschrijving" Header="Omschrijving" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView
Width="Auto"
AllowGrouping="False" IsGroupPanelMenuEnabled="False"
FocusedRow="{Binding Path=SelectedEditie, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AllowEditing="False" AllowMoveColumnToDropArea="False" AllowMoving="False"
NavigationStyle="Row" ShowGroupPanel="False"
/>
</dxg:GridControl.View>
</dxg:GridControl>
</ControlTemplate>
</dxe:ComboBoxEditSettings.PopupContentTemplate>
</dxe:ComboBoxEditSettings>
</dxb:BarEditItem.EditSettings>
I have seen other solutions where one would set the .IsOpen property of the standard ComboBox control to false, but DevExpress ComboBoxEdit doesn't have that sort of property (at least not that I know of).
Thanks!
I am now setting the ComboBoxEditSettings.PopupContentTemplate to a
GridControl.
I believe the LookUpEdit instead of combobox is better choice for you in this case:
<dxb:BarEditItem Name="bEditItem" >
<dxb:BarEditItem.EditSettings >
<dxg:LookUpEditSettings ItemsSource="{Binding ...}"
DisplayMember="..."
ValueMember="...">
</dxg:LookUpEditSettings>
</dxb:BarEditItem.EditSettings>
</dxb:BarEditItem>
Anyway, you can use the IsPopupOpen property to close popup window.

Resources