Git Product home page Git Product logo

how-to-select-all-text-in-edit-mode-in-grid-date-time-column-in-data-grid's Introduction

How to select all text in edit mode in GridDateTimeColumn in DataGrid(SfDataGrid)?

About the sample

This example illustrates how to select all text in edit mode in GridDateTimeColumn in DataGrid(SfDataGrid)?

By default, SfDataGrid enters into edit mode in GridDateTimeColumn the entire text is not selected. You can achieve this by customizing the GridDateTimeCellRenderer.

this.sfDataGridSample.CellRenderers.Remove("DateTime"); 
this.sfDataGridSample.CellRenderers.Add("DateTime", new CustomDateTimeEdit(this.sfDataGridSample));

public class CustomDateTimeEdit : GridDateTimeCellRenderer
{
    public CustomDateTimeEdit(SfDataGrid dataGrid)
    {
       DataGrid = dataGrid;
    }

    /// <summary>
    /// Gets or sets to specify the datagrid.
    /// </summary>
    protected SfDataGrid DataGrid { get; set; }

    protected override void OnInitializeEditElement(DataColumnBase column, RowColumnIndex rowColumnIndex, SfDateTimeEdit uiElement)
    {
         base.OnInitializeEditElement(column, rowColumnIndex, uiElement);

         if (DataGrid.CurrentCell != null)
         {
             if (DataGrid.CurrentCell.CellRenderer != null)
             {
                 var editingTextBox = (uiElement as SfDateTimeEdit).GetType().GetProperty("EditingTextBox", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                 (editingTextBox.GetValue(uiElement) as RichTextBox).Focus();
                 (editingTextBox.GetValue(uiElement) as RichTextBox).SelectAll();
             }
         }
    }
}

Requirements to run the demo

Visual Studio 2015 and above versions

how-to-select-all-text-in-edit-mode-in-grid-date-time-column-in-data-grid's People

Contributors

farjanaparveen avatar sarubala20 avatar vijayarasan avatar syncfusionbuild avatar

Watchers

James Cloos avatar Vijay Anand avatar Sivakumar avatar Vijayakumar Srinivasan avatar harivenkateshe avatar

Forkers

vijayarasan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.