We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DateTimePicker forecolor query

Hi,
I want to know how to change forecolor of the text
in the DateTimePickerAdv control so that in
the disable mode also i can see the text
color of the date is black.

Thanks

7 Replies

SA Saradha Syncfusion Team October 14, 2006 02:23 PM UTC

Hi Abhilash,

When you disable the dateTimePickerAdv, the textColor of the dateTimePickerAdv will also be disabled. It will not display the text color as same as when the control is enabled. You can achieve both the same forecolor and the disabled behaviour by setting the ReadOnly property of dateTimePickerAdv as true. This will display the text color as it is when the control's ReadOnly is false. Please refer to the attached sample.
Sample.zip

Please let me if you have any questions. Thanks for using Syncfusion products.

Regards,
K.Saradha Devi.


AN Abhilash N October 14, 2006 05:56 PM UTC

Hi again,
Thanks for the response and the sample as well.I got just one more question like i did for other normal window controls like Textbox -
I overrided the onpaint method and wrote a code to drawstring in black and it worked fine.But specifically DateTimepicker i inherited from the Syncfusion the same thing i tried with that also but not worked.
So it means only option is to make it Readonly than.






>Hi Abhilash,

When you disable the dateTimePickerAdv, the textColor of the dateTimePickerAdv will also be disabled. It will not display the text color as same as when the control is enabled. You can achieve both the same forecolor and the disabled behaviour by setting the ReadOnly property of dateTimePickerAdv as true. This will display the text color as it is when the control's ReadOnly is false. Please refer to the attached sample.
Sample.zip

Please let me if you have any questions. Thanks for using Syncfusion products.

Regards,
K.Saradha Devi.


SA Saradha Syncfusion Team October 16, 2006 10:07 AM UTC

Hi Abhilash,

Readonly is not the only option to fulfill your requirement. As you said, You can override the OnPaint method to set the string inside the DateTimePicker. Please refer the attached sample.
Sample.zip

Please let me know if this works for you. Thanks for using Syncfusion products.

Regards,
K.Saradha Devi,


AN Abhilash N October 16, 2006 09:20 PM UTC

It works fine except it shows the string (text) at the back of the overrided one so it is
like one over the other,adjusting the text also is not letting me to place
it exactly over the other one.
Not sure why from the back the disabled text version is visible behind the
overrided one which is black in color.

Thanks


>Hi Abhilash,

Readonly is not the only option to fulfill your requirement. As you said, You can override the OnPaint method to set the string inside the DateTimePicker. Please refer the attached sample.
Sample.zip

Please let me know if this works for you. Thanks for using Syncfusion products.

Regards,
K.Saradha Devi,


SA Saradha Syncfusion Team October 17, 2006 04:38 AM UTC

Hi Abhilash,

To make the default text invisible, you should set the Format property of the DateTimePickerAdv as custom.You can do this in the designer or add the below given code snippet in the overridden OnPaint method.

"this.Format=System.Windows.Forms.DateTimePickerFormat.Custom;"

Please let me know if I have misunderstood anything. Thanks for using Syncfusion products.

Regards,
K.Saradha Devi.


AN Abhilash N October 17, 2006 05:30 AM UTC

Hi again,
Thanks for your timely response and very clear explaination.Actually i did set the custom property but like during the Onpaint method overriding as your sample code says to set it.
Is there any other place i need to set this property.
After using the approach which you told it gives black color but yaah i want to know where to set the format property as i already set it as mentioned in your code which you have sent.

Abhilash

>Hi Abhilash,

To make the default text invisible, you should set the Format property of the DateTimePickerAdv as custom.You can do this in the designer or add the below given code snippet in the overridden OnPaint method.

"this.Format=System.Windows.Forms.DateTimePickerFormat.Custom;"

Please let me know if I have misunderstood anything. Thanks for using Syncfusion products.

Regards,
K.Saradha Devi.


AN Abhilash N October 18, 2006 05:14 PM UTC


Hi ,

It works fine now.Thanks.Can i use same from
MaskEditorTextBox control?

Please do reply.

Abhilash
>Hi again,
Thanks for your timely response and very clear explaination.Actually i did set the custom property but like during the Onpaint method overriding as your sample code says to set it.
Is there any other place i need to set this property.
After using the approach which you told it gives black color but yaah i want to know where to set the format property as i already set it as mentioned in your code which you have sent.

Abhilash

>Hi Abhilash,

To make the default text invisible, you should set the Format property of the DateTimePickerAdv as custom.You can do this in the designer or add the below given code snippet in the overridden OnPaint method.

"this.Format=System.Windows.Forms.DateTimePickerFormat.Custom;"

Please let me know if I have misunderstood anything. Thanks for using Syncfusion products.

Regards,
K.Saradha Devi.

Loader.
Live Chat Icon For mobile
Up arrow icon