How to use DateTimePicker for DateTime in PropertyGrid

Hello

given is an WPF Application with an PropertyGrid.

I have values  as DateTime I have to display time also. I found syncfusion also offer 

DateTimePicker with FullDateTime format.


How to cutomize this Control?


thank you


Lech




4 Replies 1 reply marked as answer

SN Sudharsan Narayanan Syncfusion Team February 15, 2022 08:56 AM UTC

Hi Lech,

You can be able to achieve the “Customize the DateTimePicker” requirement by using the Custom editor of the PropertyGrid and customize the DateTimeEdit control. So, please find the sample from the below,

Sample: https://www.syncfusion.com/downloads/support/forum/172833/ze/CustomEditor20532034 

Please check the sample and let us know your concerns.

Regards,
Sudharsan




LW Lech Wiecierzynski February 15, 2022 12:23 PM UTC

Thank you for the example. But DateTimeEditor doesn't fit my needs.

I rather would like to use DateTimeEdit what have the Porperty Format.

Too bad that DateTimeEdit not Implement ITypeEditor. So I could do something like this:


            editor.Editor = (ITypeEditor) new DateTimeEdit()

            {

                Pattern = DateTimePattern.FullDateTime

            };


Is it possible to fix?


Thank you


Lech



LW Lech Wiecierzynski February 15, 2022 12:30 PM UTC

Its works. Like this:


    public class DateTimeEditEx : DateTimeEdit, ITypeEditor

    {

        #region Implementation of ITypeEditor


        /// <inheritdoc />

        public void Attach(PropertyViewItem property, PropertyItem info)

        {

            //throw new NotImplementedException();

        }


        /// <inheritdoc />

        public object Create(PropertyInfo PropertyInfo)

        {

            return this;

        }


        /// <inheritdoc />

        public void Detach(PropertyViewItem property)

        {

            //throw new NotImplementedException();

        }


        #endregion Implementation of ITypeEditor

    }


Marked as answer

SN Sudharsan Narayanan Syncfusion Team February 16, 2022 02:58 AM UTC

Hi Lech,

You can be able to achieve the “Customize the DateTimePicker” requirement by using the DateTimeEdit style in Window Resource or using the Custom editor of the ITypeEditor in PropertyGrid and we can customize the DateTimeEdit control. So, please find the sample and code snippet from the below,

Code Snippet:

 
<Window.Resources> 
        <Style TargetType="{x:Type syncfusion:DateTimeEdit}"> 
            <Setter Property="Pattern" Value="FullDateTime"/> 
        </Style> 
    </Window.Resources> 

Sample: https://www.syncfusion.com/downloads/support/forum/172833/ze/CustomEditor1818276320


Please check the sample and let us know your concerns.

Regards,
Sudharsan


Loader.
Up arrow icon