This is a migrated thread and some comments may be shown as answers.

GridView date event

10 Answers 227 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Вадим
Top achievements
Rank 1
Iron
Iron
Вадим asked on 08 Mar 2018, 09:31 PM
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 (".");
         }

10 Answers, 1 is accepted

Sort by
0
Вадим
Top achievements
Rank 1
Iron
Iron
answered on 08 Mar 2018, 09:41 PM

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();
                    }

0
Hristo
Telerik team
answered on 09 Mar 2018, 12:10 PM
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.
0
Вадим
Top achievements
Rank 1
Iron
Iron
answered on 09 Mar 2018, 12:13 PM
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.
0
Hristo
Telerik team
answered on 09 Mar 2018, 12:45 PM
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.
0
Вадим
Top achievements
Rank 1
Iron
Iron
answered on 09 Mar 2018, 12:53 PM
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?
0
Hristo
Telerik team
answered on 09 Mar 2018, 01:32 PM
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.
0
Вадим
Top achievements
Rank 1
Iron
Iron
answered on 09 Mar 2018, 01:39 PM
date, month and year are allocated completely (date and month two characters, year 4 characters). How to make one symbol stand out?
0
Hristo
Telerik team
answered on 12 Mar 2018, 02:39 PM
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.
0
Вадим
Top achievements
Rank 1
Iron
Iron
answered on 12 Mar 2018, 02:52 PM
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?
0
Hristo
Telerik team
answered on 12 Mar 2018, 03:21 PM
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.
Tags
GridView
Asked by
Вадим
Top achievements
Rank 1
Iron
Iron
Answers by
Вадим
Top achievements
Rank 1
Iron
Iron
Hristo
Telerik team
Share this question
or