Category / Section
How to enable entry in one column when clicking a button in another column of the same row?
1 min read
We can enable an entry in one column when clicking a button in another column of the same row by changing the IsEnabled property of the entry in the button click.
Refer the below code example in which an Entry and a Button is loaded as column element using GridTemplateColumn in SfDataGrid.
<sfGrid:SfDataGrid x:Name="dataGrid" AutoGeneratingColumn="DataGrid_AutoGeneratingColumn" AutoGenerateColumns="True" ColumnSizer="Star" ItemsSource="{Binding OrdersInfo}"> <sfGrid:SfDataGrid.Columns> <sfGrid:GridTemplateColumn MappingName="OrderID"> <sfGrid:GridTemplateColumn.CellTemplate> <DataTemplate> <Entry IsEnabled="{Binding IsEnabled}" Text="{Binding OrderID}" TextColor="Black" /> </DataTemplate> </sfGrid:GridTemplateColumn.CellTemplate> </sfGrid:GridTemplateColumn> <sfGrid:GridTemplateColumn MappingName="CustomerID"> <sfGrid:GridTemplateColumn.CellTemplate> <DataTemplate> <Button Clicked="dataGrid_Clicked" Text="{Binding CustomerID}" TextColor="Black" /> </DataTemplate> </sfGrid:GridTemplateColumn.CellTemplate> </sfGrid:GridTemplateColumn> </sfGrid:SfDataGrid.Columns> </sfGrid:SfDataGrid>
The below code illustrates how to enable the IsEnabled property of an entry when the button on the same row is clicked.
private void dataGrid_Clicked(object sender, EventArgs args) { var data = ((sender as Button).BindingContext as OrderInfo); data.IsEnabled = true; }
Screenshot
Sample Link
How to enable textbox in one column when clicking a button in another column of same row?