Question displaying datepicker in datagrid

svibuk

Active member
Joined
Jul 15, 2008
Messages
31
Programming Experience
1-3
have a datagrid in windows forms .
i need to display datepicker in 2 columns and the date selected if then 2 be saved in database
if no date selected for a particular row then it shld not be saved
 
This will get you started:

How to: Host Controls in Windows Forms DataGridView Cells

The DateTimePicker dies support null values by default, so you will have to fiddle with it a bit to do that. Generally speaking, people use the Checked property to indicate whether a value is selected or not.
 
I would rather use a text cell instead, with validations to make sure the entry is an actual date, and a dialogbox (triggered by a button or by the event of entering the cell) containing a MonthCalendar to offer the user who wants it a visual support when selecting a date. It seems simpler.
 
I would rather use a text cell instead, with validations to make sure the entry is an actual date, and a dialogbox (triggered by a button or by the event of entering the cell) containing a MonthCalendar to offer the user who wants it a visual support when selecting a date. It seems simpler.

It may be simpler to code but it may not produce as satisfying a user experience. The good thing about things like custom DataGridViewColumns is that you can just create them once and put them in a library and then use them in as many projects as you like, so sometimes it is worth putting in the extra effort.

That's not to say that yours is a bad idea. The main issue I see with it is that it doesn't prevent the user entering an invalid value but rather chides them for it afterwards. The best thing about it is that it handles null values easily. There's generally pros and cons to everything.
 
It may be simpler to code but it may not produce as satisfying a user experience. The good thing about things like custom DataGridViewColumns is that you can just create them once and put them in a library and then use them in as many projects as you like, so sometimes it is worth putting in the extra effort.

That's not to say that yours is a bad idea. The main issue I see with it is that it doesn't prevent the user entering an invalid value but rather chides them for it afterwards. The best thing about it is that it handles null values easily. There's generally pros and cons to everything.

Yes, I understand that. Since the beginning I knew the solution you pointed out is the best accomplishment of what is devised here. The alternative I mentioned may serve better to those who are less experienced and would fear to deal with something with that complexity at this point. That would be my case at the present moment, for instance.
 
Back
Top