Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get width of button in DateTimePicker-Control/Controls in general?

I implemented a custom DateTimePicker. On the DateTimePicker there is a button. In the examples I've found it's width is set to 16. This is working but I would like to have a dynamic approach.

So, is there a way to get the size of this button or is there a general way to get information about .Net-Control sub elements like size etc.?

Trying DateTimePicker.Controls didn't help me (it's empty).

enter image description here

like image 460
Inno Avatar asked Nov 06 '22 20:11

Inno


1 Answers

Most all Win32 arrow buttons key off the scroll bar metric:

You want SystemInformation.VerticalScrollBarArrowHeight

Two helpful classes: SystemInformation and ControlPaint. When dealing with custom controls they can be invaluable.

Int32 size = SystemInformation.VerticalScrollBarArrowHeight;
ControlPaint.DrawScrollButton(e.Graphics, 0, 0, size, size, ScrollButton.Down, ButtonState.Normal);
like image 153
John Arlen Avatar answered Nov 14 '22 10:11

John Arlen