WinForms Gantt View - date input format

2 Answers 102 Views
GanttView
Jacek
Top achievements
Rank 2
Iron
Iron
Iron
Jacek asked on 08 Apr 2022, 10:15 AM | edited on 08 Apr 2022, 10:21 AM
Hi,
When modifying the value in the column, eg "Start", I need the control that supports entering the date to be displayed in the ShortDateString mode.
I tried to capture a control in the ControlAdded event, but I am capturing the HostedTextBoxBase, not the DateTimePicker.

 


    Private Sub RadGanttView1_ControlAdded(sender As Object, e As ControlEventArgs) Handles RadGanttView1.ControlAdded
        Dim startDate As Date = RadGanttView1.SelectedItem.Start
        e.Control.ResetText()
        e.Control.Text = startDate.ToShortDateString
    End Sub


How can I change the date input format to Short?

Regards
Jack

 

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 13 Apr 2022, 06:37 AM

Hello Jacek,

Thank you for the provided code snippet.

To change the date format of a specific column, you can set the FormatString property of this column. For example, you can get all columns in the Columns collection property of the RadGanttView. Then you just set the date format as per your requirement. The following code snippet demonstrates this. On my side, the Start column is the first column. 

this.radGanttView1.Columns[0].FormatString = "{0:MM / dd / yyyy}";

I hope this approach will work for you. 

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Jacek
Top achievements
Rank 2
Iron
Iron
Iron
answered on 26 Jul 2022, 05:37 PM | edited on 26 Jul 2022, 08:33 PM

Hi Dinko
Thanks for your code.

I found a solution:


Public Sub New()

'Add handler
        AddHandler Me.RadGanttView1.GanttViewElement.EditorInitialized, AddressOf editorInit

End Sub

Sub editorInit(sender As Object, e As GanttViewItemEditorInitializedEventArgs)
        Dim dtEditor As GanttViewDateTimeEditor = TryCast(e.Editor, GanttViewDateTimeEditor)
        If dtEditor IsNot Nothing Then
            dtEditor.CustomFormat = "dd/MM/yyyy"
         End If
    End Sub
Dinko | Tech Support Engineer
Telerik team
commented on 27 Jul 2022, 11:32 AM

I am happy to hear that you have found a solution for your case and thank you for sharing it. If you have any further questions, feel free to open a new ticket and we will be happy to help.
Tags
GanttView
Asked by
Jacek
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Jacek
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or