GridView date event

11 posts, 0 answers
  1. Вадим
    Вадим avatar
    20 posts
    Member since:
    Mar 2016

    Posted 08 Mar 2018 Link to this post

    The column changes and has a date format.
    how to hang an event is not a change to ValueChanged?
    I want to apply this code:
    private void dateTime_ValueChanged (object sender, EventArgs e)
             {
                 SendKeys.Send (".");
             }
  2. Вадим
    Вадим avatar
    20 posts
    Member since:
    Mar 2016

    Posted 08 Mar 2018 Link to this post

    load grid:

    radGridView6.DataSource = _bindingSource_personel_time;

                        if (radGridView6.Columns.Count > 0)
                        {
                            radGridView6.Columns[0].IsVisible = false;
                            radGridView6.Columns[1].FormatString = "{0:dd/MM/yyyy}";
                            radGridView6.Columns[2].FormatString = "{0:dd/MM/yyyy}";

                            radGridView6.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                            UpdateLoadJobTime();
                        }

  3. Hristo
    Admin
    Hristo avatar
    1506 posts

    Posted 09 Mar 2018 Link to this post

    Hello Вадим,

    I am not really sure that I quite well understand your question. If you would like to be notified that a value in the grid has changed, you can handle the RadGridView.CellValueChanged event. More information about how changes can be tracked in RadGridview is available here: https://docs.telerik.com/devtools/winforms/gridview/insert-update-delete-records/tracking-changes-in-radgridview.

    In case you need further assistance please elaborate on your question and let me know in details what you are trying to accomplish.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. Вадим
    Вадим avatar
    20 posts
    Member since:
    Mar 2016

    Posted 09 Mar 2018 in reply to Hristo Link to this post

    my date is in the grid in the format dd.mm.yyyy.
    I want to make it so that the user does not enter the point itself. "".
    Just entered the numbers, and the dot itself was put.
  5. Hristo
    Admin
    Hristo avatar
    1506 posts

    Posted 09 Mar 2018 Link to this post

    Hi,

    First, you will need to set the CustomFormat property of the column which controls how the text inside the editor is formatted. Then you can handle the CellEditorInitialized event and set the AutoSelectNextPart property on the DateTime provider: 
    public Form1()
    {
        InitializeComponent();
         
        //Setup the grid
     
        GridViewDateTimeColumn dateTimeColumn = (GridViewDateTimeColumn)this.radGridView1.Columns["Date"];
        dateTimeColumn.Format = DateTimePickerFormat.Custom;
        dateTimeColumn.FormatString = "{0:dd/MM/yyyy}";
        dateTimeColumn.CustomFormat = "MM.dd.yyyy";
         
        this.radGridView1.CellEditorInitialized += RadGridView1_CellEditorInitialized;
    }
     
    private void RadGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    {
        RadDateTimeEditor dateTimeEditor = e.ActiveEditor as RadDateTimeEditor;
        if (dateTimeEditor != null)
        {
            this.radGridView1.CellEditorInitialized -= RadGridView1_CellEditorInitialized;
            RadDateTimeEditorElement editorElement = (RadDateTimeEditorElement)dateTimeEditor.EditorElement;
            MaskDateTimeProvider provider = editorElement.TextBoxElement.Provider as MaskDateTimeProvider;
            if (provider != null)
            {
                provider.AutoSelectNextPart = true;
            }
        }
    }

    I am also attaching a short video showing the result on my end.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Вадим
    Вадим avatar
    20 posts
    Member since:
    Mar 2016

    Posted 09 Mar 2018 in reply to Hristo Link to this post

    Thank you. exactly what is needed. I would like to ask you how to do this:
    The date, month and year are fully allocated. How to make so that on one character stood out?
  7. Hristo
    Admin
    Hristo avatar
    1506 posts

    Posted 09 Mar 2018 Link to this post

    Hi Вадим,

    Can you please elaborate on your question? 

    Looking forward to your reply.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  8. Вадим
    Вадим avatar
    20 posts
    Member since:
    Mar 2016

    Posted 09 Mar 2018 in reply to Hristo Link to this post

    date, month and year are allocated completely (date and month two characters, year 4 characters). How to make one symbol stand out?
  9. Hristo
    Admin
    Hristo avatar
    1506 posts

    Posted 12 Mar 2018 Link to this post

    Hello,

    You can use a different format string, e.g. like this one: 
    GridViewDateTimeColumn dateTimeColumn = (GridViewDateTimeColumn)this.radGridView1.Columns[2];
    dateTimeColumn.Format = DateTimePickerFormat.Custom;
    dateTimeColumn.FormatString = "{0:d/M/yyyy}";
    dateTimeColumn.CustomFormat = "d.M.yyyy";

    I hope this will help.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  10. Вадим
    Вадим avatar
    20 posts
    Member since:
    Mar 2016

    Posted 12 Mar 2018 in reply to Hristo Link to this post

    You misunderstood me.
    Here is the date of 12/03/2018.
    I'm starting to edit it.
    The first character is selected, i.e. 1 after pressing a key for example 2, the date is changed and goes to the next character 2, when another keys is made, it goes to the next one.
    Those. selection and change is one character at a time.
    Can so it is more clear?
  11. Hristo
    Admin
    Hristo avatar
    1506 posts

    Posted 12 Mar 2018 Link to this post

    Hello,

    Whether an editable element will be selected or not is determined by the AutoSelectNextPart property of the provider. If you do not want to automatically select other date parts do not set it to true. If you want to have a custom behavior you can create a custom mask provider and substitute the default one in the CellEditorInitialized event. In your custom implementation, you will need to override the SelectNextEditableItem method. It is declared virtual so you should be able to customize it.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top