Posted 15 July 2022, 2:43 am EST
When we start to edit in a cell, X is appear in right side.
Could I know how to dissapear this X ?
Forums Home / ComponentOne / WinUI Edition
Posted by: munemoto on 15 July 2022, 2:43 am EST
Posted 15 July 2022, 2:43 am EST
When we start to edit in a cell, X is appear in right side.
Could I know how to dissapear this X ?
Posted 15 July 2022, 5:11 am EST
Hi Tugu,
This behavior is specific to MS TextBox. It displays the ‘x’ sign when its TextWrapping property is set to 'NoWrap’.
You can overcome this behavior by setting the TextBox’s TextWrapping property to WordWrap inside FlexGrid’s PrepareCellForEdit event as follows:
private void OnPrepareCellForEdit(object sender, GridCellEditEventArgs e)
{
if(e.Editor is TextBox texBox)
{
texBox.TextWrapping = TextWrapping.Wrap;
}
}
Or you can also remove the delete button from the Template by overriding TextBox’s OnApplyTemplate method as follows:
public class CustomTextBox : TextBox
{
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
var deleteButton = GetTemplateChild("DeleteButton") as Button;
var grid = VisualTreeHelper.GetChild(this, 0) as Grid;
grid.Children.Remove(deleteButton);
}
}
And then set it to FlexGrid GridColumn’s CellEditingTemplate as follows:
<c1:FlexGrid.Columns>
<c1:GridColumn Binding="Name">
<c1:GridColumn.CellEditingTemplate>
<DataTemplate>
<local:CustomTextBox Padding="7, 7, 0, 0"
Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></local:CustomTextBox>
</DataTemplate>
</c1:GridColumn.CellEditingTemplate>
</c1:GridColumn>
</c1:FlexGrid.Columns>
Please refer to the same from the attached sample. (see FlexGridEdit.zip)
Best Regards,
Kartik
Posted 19 July 2022, 10:31 pm EST
Hi, Kartik
It works completely!
Thank you!