Hi,
I've created a date time user control that better suit the need of my client. It's composed of a UltraMaskedEdit and a MonthCalendar.
Everything is working fine on it's own. When I try to use it inside a grid, nothing seems to work.
I've attached a small sample project to demonstrate. The date shows as "01--" instead of "2011-12-01". Updating the value is not working, either by manually entering it or using the embedded MonthCalendar.
I know that implementing a user control inside a grid is a hard job, but I can't seem to figure out where to begin.
Any help would be appreciated
Chris.NetAdvantage Vol 2010.2
I think you are going to have a pretty hard time getting any of the editors to do this for you. There's no way to stop the editor from formatting the dates, so keeping exactly what the user typed in a situation where there is a mask and a format will be tricky if not impossible.
ChrisBel said: - Add properties to be able to easily bind to either a DateTime or DateTime?
Huh? I think you made a typo there.
I'm not sure what the best approach would be to acheive this - it seems pretty complex to me. Maybe you would be better of writing your own control and using the UltraControlContainerEditor. Or, you might want to try using UltraCalendarCombo, instead of UltraDateTimeEditor. Or, perhaps a normal text editor would be better and you could just validate the text entered into the cell yourself using the BeforeCellUpdate event.
Hi Mike,
What I'm trying to achieve with this custom control is the following: - Allows date below the 1753-01-01 to be manually entered - Never change the date automatically: ie 20-12-31 will become 2020-12-31 - Prevent the control to modify the date manually entered: ie entering '2', '0', '0', '1', '1', '3' will give "2001-1-3". - Allow the user to enter invalid date and have an errorProvider or message box instead: ie 2001-13-33 - Add properties to be able to easily bind to either a DateTime or DateTime?
Would it be maybe simpler, since I have your source code, to try to modify the UltraDateTimeEditor? Or am I going down an even riskier road.
I'll try to look at the UltraControlContainerEditor and see where this leads me.
Thanks
Hi Chris,
It's tough to tell, without really spending a huge amount of time reading this code, what you are trying to do here.
It looks like what you want is a Masked editor that drops down a MonthCalendar control. But why are you jumping through hoops to do this yourself instead of just using the DateTimeEditor - or the grid's default editor for any DateTime column.
What kind of functionality are you trying to add here?
When you embed an editor in the grid, that editor is going to get a whole lot of information from the grid column and ignore a whole lot of information on the control. So creating your own control that contains an UltraMaskedEdit control and returns the editor that that control provides is basically the same as simply setting the EditorControl property on the column to the UltraMaskedEdit control. Nothing you do to the Control will affect anything in the grid.
If you want to embed your own control in a grid cell, then trying to implement or mess around with the IProvidesEmbeddableEditor interface it incredibly complex and difficult and I don't think this approach is going to get you what you want.
It will be much easier and save you a lot of time to use the UltraControlContainerEditor component to embed your control directly into the cell, instead of trying to write your own custom editor.