I am using a dateTimePicker control which enable property currently set as false. I want to enable the control on doubleClick but doubleClick event is not available with dateTimePicker.
Asked
Active
Viewed 132 times
-1
-
1Hi Ajeet, can you add some example code? – KevinLamb Oct 08 '19 at 14:05
-
2A disabled control will not respond to any events. – LarsTech Oct 08 '19 at 14:06
2 Answers
1
You could put a transparent Panel on top of the DateTimePicker
:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
TransparentPanel panel = new TransparentPanel()
{
Location = dateTimePicker1.Location,
Size = dateTimePicker1.Size,
};
this.Controls.Add(panel);
panel.DoubleClick += Panel_DoubleClick;
panel.BringToFront();
}
private void Panel_DoubleClick(object sender, EventArgs e)
{
dateTimePicker1.Enabled = true;
}
}

mm8
- 163,881
- 10
- 57
- 88
0
I'm not sure why you would want to do this, but you can place the dateTimePicker control inside a System.Windows.Forms.Panel control. In the panels doubleClick event enable the dateTimePicker. See below.
private void panel1_DoubleClick(object sender, EventArgs e)
{
this.dateTimePicker1.Enabled = true;
}

Kevin
- 2,566
- 1
- 11
- 12