I want to dissapear X in Cell Editor in FlexGrid

Posted by: munemoto on 14 July 2022, 5:43 pm EST

    • Post Options:
    • Link

    Posted 14 July 2022, 5:43 pm EST

    When we start to edit in a cell, X is appear in right side.

    Could I know how to dissapear this X ?

  • Posted 14 July 2022, 8:11 pm 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

    FlexGridEdit.zip

  • Posted 19 July 2022, 1:31 pm EST

    Hi, Kartik

    It works completely!

    Thank you!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels