C
C#8mo ago
Core Dream

BindModel with DateTimePicker

I have a simple WinForms Dapper ORM w/SQLite app I've written, everything works except binding to the DateTimePicker controls. My model:
namespace TaskMinder.Model;

public class Entry
{
public int Id { get; set; } = 0;
public DateTime EntryDate { get; set; }
public DateTime EntryTime { get; set; }
public string EntryData { get; set; } = string.Empty;
}
namespace TaskMinder.Model;

public class Entry
{
public int Id { get; set; } = 0;
public DateTime EntryDate { get; set; }
public DateTime EntryTime { get; set; }
public string EntryData { get; set; } = string.Empty;
}
My method:
private void BindModel(Entry model)
{
NewEntryDatePicker.DataBindings.Add("Value", model, "EntryDate", true, DataSourceUpdateMode.OnPropertyChanged);
NewEntryTimePicker.DataBindings.Add("Value", model, "EntryTime", true, DataSourceUpdateMode.OnPropertyChanged);
NewEntryTextBox.DataBindings.Add("Text", model, "EntryData", true, DataSourceUpdateMode.OnPropertyChanged);
}
private void BindModel(Entry model)
{
NewEntryDatePicker.DataBindings.Add("Value", model, "EntryDate", true, DataSourceUpdateMode.OnPropertyChanged);
NewEntryTimePicker.DataBindings.Add("Value", model, "EntryTime", true, DataSourceUpdateMode.OnPropertyChanged);
NewEntryTextBox.DataBindings.Add("Text", model, "EntryData", true, DataSourceUpdateMode.OnPropertyChanged);
}
What am I doing wrong? Thank you in advance.
2 Replies
SpReeD
SpReeD8mo ago
The bindings looks okay, have you tried using the other overload?
NewEntryDatePicker.DataBindings.Add("Value", model, "EntryDate");
NewEntryTimePicker.DataBindings.Add("Value", model, "EntryTime");
NewEntryDatePicker.DataBindings.Add("Value", model, "EntryDate");
NewEntryTimePicker.DataBindings.Add("Value", model, "EntryTime");
Core Dream
Core DreamOP8mo ago
I'll give it a shot when I get up, thank you for the help.
Want results from more Discord servers?
Add your server