public static void DateReset(object sender, KeyPressEventArgs e) { try { Guna2DateTimePicker Date = (Guna2DateTimePicker)sender; if (e.KeyChar == (char)Keys.Escape || e.KeyChar == (char)Keys.Back || e.KeyChar == (char)Keys.Delete) { Date.CustomFormat = " "; } } catch (Exception ex) { MessageBox.Show("Houve um erro ao resetar a data (" + ex.Message + ")"); } }
private void createDatePicker(PropertyInfo property, Label label, int x, int y, DateTime value) { Guna2DateTimePicker datePicker = new Guna2DateTimePicker() { Value = value, Location = new System.Drawing.Point(x += 120, y), Tag = property, CustomFormat = "dd/MM/yyyy", Format = DateTimePickerFormat.Custom, FillColor = Color.LightBlue, ForeColor = Color.Black, }; formGroupBox.Controls.Add(label); formGroupBox.Controls.Add(datePicker); }
public static void DateTimeValueChanged(object sender, EventArgs e) { try { Guna2DateTimePicker Date = (Guna2DateTimePicker)sender; if (Convert.ToString(Date.Value) != Convert.ToString(DateTime.Now)) { Date.CustomFormat = "dd/MM/yyyy HH:mm"; } else { Date.CustomFormat = " "; } } catch (Exception ex) { MessageBox.Show("Houve um erro ao converter a data (" + ex.Message + ")"); } }