Reputation: 853
I have a grid control where some columns are editable, some are not.
I'd like to have more fine control, so that depending on some other fields of MyData
, the corresponding cells will be enabled or not.
<dxg:GridControl ItemsSource="{Binding MyData}" AutoPopulateColumns="True">
<dxg:GridControl.Columns>
<dxg:GridColumn Header="Name" ReadOnly="True"/>
<dxg:GridColumn Header="ID 1" ReadOnly="False"/>
<dxg:GridColumn Header="ID 2" ReadOnly="False"/>
<dxg:GridColumn Header="ID 3" ReadOnly="False"/>
</dxg:GridControl.Columns>
</dxg:GridControl>
Can't find anything on the DevExpress support site yet. Would you please have any idea?
Thank you!
Upvotes: 0
Views: 4507
Reputation: 17850
You can accomplish this task via handling the ShowingEditor event. You can set e.Cancel
to True
if a cell shouldn't be edited:
void TableView_ShowingEditor(object sender, DevExpress.Xpf.Grid.ShowingEditorEventArgs e)
{
if(...)
{
e.Cancel = true;
}
}
You can also accomplish this task via XAML style:
<Style TargetType="dxg:CellContentPresenter" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=CellStyle}}">
<Setter Property="IsEnabled" Value="{Binding Path=RowData.Row.SomePropertyRelatedToEnabledState}"/>
</Style>
Upvotes: 1