I am using a month calendar for user to enter data range. But when user scrolls through months, the selected range is changed automatically.
Why is that happening and how can I make that selectionstart and selectionend properties are changed only when I manually select range in MonthCalendar?
In Msdn (and elsewhere) I had no luck to find information about this behavior, anyone has a clue?
http://msdn.microsoft.com/en-us/library/System.Windows.Forms.MonthCalendar_properties(v=vs.110).aspx
Related
I've tried implementing the first suggestion from C# Winforms DataGridView Time Column, i.e. showing a DateTime picker in a DataGridView.
However, when I launch the app and select a date from the dtPicker and then select the next row, the value disappears in the first cell where I had selected a date.
What changes are needed for the cell to keep displaying its value while creating additional rows in the DataGridView?
I found another solution, which solved the issue. It's much cleaner and easier to implement. The solution was in an article titled:
Embedding Calendar (DateTimePicker) Control Into DataGridView Cell
https://www.c-sharpcorner.com/UploadFile/0f68f2/embedding-calendar-datetimepicker-control-into-datagridvie586/
The code suggestions in the above article work well for every row in the DGV.
I have a user control that handles both creating and editing an object. I'm setting a week of BlackOutDates on a DatePicker. If the date that the DatePicker's SelectedValue property is bound to falls on a blackout date, it throws an ArgumentOutOfRangeException (as is documented here: http://msdn.microsoft.com/en-us/library/system.windows.controls.datepicker.selecteddate%28VS.95%29.aspx).
How do I handle this exception when it is occurring during data binding? The binding's ExceptionValidationRule only handles exceptions that occur when updating the source property. Ideally I'd like to display whatever value is already set, but have it fail validation. Like if you had a textbox with a validation rule that said it only allows the letter "a". If you bind a property set to the string "zzzzz", it's not going to blow up the application and be incapable of displaying the value, it will just fail validation.
After thinking about it, I think I'm mistakenly mixing up the concepts of blackout dates and validation. The datepicker's blackout dates are a presentational feature, not a validation mechanism. So what I've done is when the control loads, if my bound object's date occurs on a blackout date, I don't black it out. You can't have a blacked out date selected, so this is the only option. In the selected date changed event handler, I reassess the blackout dates and black them out if the selected date no longer occurs on one. So once I choose a valid date, I can't change it back to a blacked out date. Then I added an additional validation rule to make sure the control can't save if the selected date occurs on an invalid date.
On a SearchScreen, I have some properties to filter my table results.
ComboBox for the month.
ComboBox for the year.
ComboBox for a customer (based on a query with two parameters, DateBegin, DateEnd)
The third ComboBox need to be filtered to only show customers that are 'active' in the selected period from Month and Year Comboboxes.
I use two properties (Date) named 'prpDateBeginSelected' and 'prpDateEndSelected', linked to my query herself linked to the ComboBox of the customers.
I use the _Changed events on my Month and my Year to assignate the dates to the properties.
When I make my first selection after the screen was loaded, It work and the customer combobox is filtered in the good period.
But after, when I change the month or the Year, the customers comboBox don't reload.
I've tried to do a this.qCustomersByPeriod.Refresh(); in my code but no changes.
Thanks for help.
PS : If needed, I can make you a sample to show you the idea.
EDIT : A sample to help you understand me. LS_SearchFiltered.zip (58.6 Mo)
It's good that you provided your solution, because I got confused just from the explanation from the post. Indeed the problem with your solution was data binding. You've mistaken the data binding for QueryDataByCustomerAndPeriod.CustomerId it should be QueryCustomersByDate.SelectedItem.Id . Also instead of using generic prpCustomer, you need to use the selected item of QueryCustomersByDate and get the relevant Id. To clarify everything see the screenshots below. Hope this solves your problem.
A note to remember - check carefully your data biding in the View-Model - what links to what.
Problem in QueryDataByCustomerAndPeriod.CustomerId
Correct the binding in QueryDataByCustomerAndPeriod.CustomerId
I am building a silverlight 4 application and the user wants to have a autocompelte feature for
date controls. ( Note I am using the DatePicker). For e.g. when the user types 5 and tabs out
the date should be converted to 5'th of sept 2012 becuase 5'th august has gone past. I also have
some other rules that are in place for this date formation. I planned to write some code
for this one in the KeyUp event but I am unable to get the text that the user has entered in the
datepicker. Also TextInputStart and TextInputUpdate are never called in my case.
I am looking for the correct event in which I can get what the user has entered
Thanks
Amol
I had a similar problem once with the DatePicker of the Silverlight Toolkit. The only way I could solve that was to create a new UserControl using a standard TextBox and a DatePicker. I re-styled the DatePicker so that its default text area remained hidden, and replaced it by the standard TextBox.
I wired the DatePicker's SelectedDate-Property to the Text-Property of the TextBox, so that it would get updated once someone picks a date.
In your case you could use the AutoCompleteBox coming with the Toolkit instead of a standard TextBox and then use some clever logic to prefill the list of auto-complete proposals. Thus your control would look like a standard DatePicker, and mostly behave like one, but would provide a mixed functionality of DatePicker, TextBox and AutoCompleteBox.
I have a numericUpDown picker that's set to a range of acceptable years, defaulting to the current year.
The user can edit the number in the box with the keyboard: say if the number in there is 2011 to begin with, they can press backspace and the number in the box on screen will be 201. However, as far as I know, the value property of the control will never read a number below the minimum I set (1900 in this case).
I need a way to get the number currently in the box on the screen regardless of whether it is in my acceptable range or not. Anyone know how to do this?
Thanks!
You can use the NumericUpDown.Text property to get the current text, then parse to int. It may not look like the property exists, but it's there.
The Text has no affect on the appearance of the NumericUpDown control; therefore, it is hidden in the designer and from IntelliSense.