DateTimePicker: Use neither calendar nor spin button - winforms

I want to take advantage of DateTimePicker's date validation, but the calendar seemed cumbersome to our customers for setting the date (they'd rather do it using just the keyboard, tabbing their way through the form).
So I took a long look at the documentation and found that one way to get rid of the calendar was setting the ShowUpDown property to true. So I got this:
However, our customers are now saying that they don't want to use the spin button, and therefore they don't want it to be visible/accesible. i.e. they want this:
However, if i set ShowUpDown to false, I'm back to the calendar. Is there another way?

Had to roll my own Custom Control. Luckily, some other guy from the team has already written custom controls so I have example code to get started. Anyway, what good is a framework if I have to do this kind of things myself? Hope they solved this in .net 4.5...
EDIT: Using a MaskedTextBox with ValidatingType = typeof(System.Date) is a better solution. Sorry .NET!

Related

FullCalendar Does NOT Support "Tap/Touch" Select/Create Event? without holding?

from my understanding, the only way to select a timeslot on the calendar from a touch device is to tap and hold, I'm looking for a way to handle tap in the same way the calendar grid handles on click. I do not see a way to do this in the documentation.
https://fullcalendar.io/docs/touch
The answer to my question was provided by ADyson in a comment:
If it's not documented then it's unlikely to exist. I'm not aware of
anything else. The reason is probably because you can actually drag to
select a larger time slot, and also tapping is probably considered
like a "click" on the day, which triggers a different callback event.
I suspected that this would be the case, but I'm not super familiar with FullCalendar, so I wanted to double-check in case I was missing something.

Read data from a form in backbone

I'm working on a Backbone application, and I have almost everything working, except the way I should read data from a form.
I have a few views and templates that create the form elements, and a "save" button. When I click that button it fires a view event, and there is where I would like to know if there is a "best practice" to read that info.
The options I was thinking were:
Reading the inputs using jQuery, like jQuery('#name').val(), which
would be annoying if you have a big form.
Using serializeArray
The last one would be something like https://github.com/derickbailey/backbone.syphon, but not sure how popular is it.
So, which is the best "backbone way" to do it?
Thanks a lot!
What is the best way is hard to say as it depends.
The example you show in your post are all meant for one action: submitting a form to a backend. Then, syphon (made by a great developper) and serializeArray (or just $(form).serialize()) are great solution (obviously the first one isn't great for a big form - so I'd forget this one).
Although, if your form is meant to update a model in realtime, and that this form should reflect change to model. Then, I'd go for a data-binding library. The best I know is Backbone.stickit; there's also Backbone.ModelBinder. I used both and they're great, although the first one use a little bit less boilerplate.

A better way of managing a forms state?

I am new to Windows programming, as in my previous work I've mostly been involved with web technologies, and mostly in the backend. I have inherited a Winforms application, and one of my biggest nightmares is navigating through the endless states a form can be in.
To give you an example, a form has the state 'New' and 'Edit' depending on whether the user decided to Add or Edit a record. On this form, we have logic. If this texbox has a certain value, then these other textboxes are disabled, etc. This leads to endless chaining of these rules. So, a textbox's TextChanged event will influence another field. It in turn will fire X event that changes the state of other controls. It quickly devolves into a tangled mess that is impossible to maintain.
There has to be a better way... something simple and elegant that solves this problem. Any suggestions?
What I do is to have a single method called FormatControls(). In this method, I implement all the logic such as myTextbox.Enabled = mycheckBox.Checked and so on.
I call this method from my event handlers in the form, such as on checked changed, etc... I also call it when appropriate (ie, form newly loaded with no data, record loaded from database, etc). This has suited me well for many years now, it makes everything less complex.
You are correct, if you do not have a pattern in use it can turn into a too-complex thing.
You can try to use tha Application.Idle event to perform the enable disable logic and insulate this part from the business logic part.
Depending on what controls you have on your form, you might be able to do away with the separate textboxes and add/delete buttons and replace the whole works with a DataGrid.

wpf calendar control - subclass

I have the word "subclass" in the title because that's the only idea I have for doing this, but maybe not?
What I need is to only use the years of a calendar control - I don't need either the months view nor the days view. I thought of writing a custom control that does this, but since calendar already has the very cool "Decade" view, I wanted to use that.
I tried handling the DisplayDateChanged event and forcing the mode back to Decade, but what happens is that the months show on click, and then disapear showing the Decade view again.
Any "interesting hacks" for doing this?
In C++, I always knew I can do a "real subclass" and intervene in the control's behavior - Can this be done?
Check out this article on styling for the Calendar control, it may get you started.
http://msdn.microsoft.com/en-us/magazine/dd882520.aspx

WPF Combobox bug when form allowtransparency=true

I have found the following in WPF:
I have a form with AllowTransparency=true. Inside the form I put a Combobox.
I add some items to the combobox.
I run this application and click on the combobox. At first it does not seem to appear at all. On closer inspection (after adding more items) I see that it is actually appearing behind the form. If I add enough items it become visible from behind the form.
If I just change AllowTransparency=false, then all is fine.
This looks like a bug in WPF (3.5 SP1).
Any one know of a workaround for this?
Go to
https://connect.microsoft.com/dashboard/?wa=wsignin1.0
submit your feedback after searching #
https://connect.microsoft.com/VisualStudio
https://connect.microsoft.com/VisualStudio/feedback/CreateFeedbackForm.aspx?FeedbackFormConfigurationID=1160&FeedbackType=1
and mention steps to reproduce.
There was an update of 3.5sp1 but you could test,but I doubt
http://www.microsoft.com/downloads/details.aspx?familyid=6c095bba-6100-4ec9-9c54-6450b0212565&displaylang=en
AllowTransparency is slow and buggy and shouldn't be used - it's a great way to run into bug in various display drivers.
You can get almost anything you like without using AllowTrasparency, take a look at this post for examples:
http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx

Resources