I am writing an application which updates the date selected in RadCalender to a database column on click of a button.
After the button is clicked, i want to clear the selected date so that the end user selects a date before clicking the button again
I have tired using the below code, but it dosen't appear to work
calExpirydate.SelectedDates.Clear();
You can use the following script:
var selectedDates = get_selectedDates(); //Gets the "list" of selected dates
unselectDates(selectedDates); // unselects all dates that may have been selected.
Code taken from: Telerik Reset Calendar Selected Date
----------------------------
radCal1.RemoveFocusedDate(true); //Will remove the calendar date currently selected.
Related
Hello i have database called tbl_data, that have name,address, and 'date' type of data
example : 12/5/2021 (the data saved like this in my db)
I use datetimepicker toolbox to insert date into database,
now i have 1 data of a date inside my database
I try to show the data into Datetimepicker box, the idea is when I click 1 of data from Datagridview, its show 1 set of Data (name,date,address)
my question is
with this code I already success showing the name and address(which is a string), how can I show the date into this datetimepicker toolbox?
thank you
private void dgvData_DoubleClick(object sender, EventArgs e)
{
if(dgvData.CurrentRow.Index != -1)
{
Id = Convert.ToInt32(dgvData.CurrentRow.Cells[0].Value.ToString());
txtName.Text = dgvData.CurrentRow.Cells[1].Value.ToString();
txtAddress.Text = dgvData.CurrentRow.Cells[2].Value.ToString();
//dateTimePicker1.Text = dgvData.CurrentRow.Cells[3].Value.ToString();
// yea this code doesnt work because it convert to string but the toolbox was was not textbox but datetimepicker
}
}
You can simplify this if the grid uses a DataSource. Assuming that tbl_data is used as a DataSource to the grid, then instead of “manually” changing the data in the text boxes and date time picker, when the grid row is double clicked… you could set each text box and the date time picker's DataBindings property.
This will change the text in the text boxes and date time picker automatically when the user selects a different row in the grid... and your code will no longer need to "manually" set the values as your current code does. Something like…
txtName.DataBindings.Add("Text", tbl_data, "Name");
txtAddress.DataBindings.Add("Text", tbl_data, "Address");
dateTimePicker1.DataBindings.Add("Text", tbl_data, "Date");
Where, “Name” is the name of the “Name” column in tbl_data and the same applies to the “Address” column name and “Date” column name.
In addition, if the user changes the text in one of the text boxes or changes the date time picker value… then the grid will automatically reflect those changes.
I have a datetime picker in windows form. When i am selecting a date it shows the last selected date and current date. But i want to shows only current date always. It should not show last selected date and current date(both) on the selection dropdown.
public FieldControl()
{
InitializeComponent();
dtpDate.Value = DateTime.Now;
}
Hello Kumar is right,
but what is sense of selectable date and time component where is only one option to select?
Isn't better to make datetimepicker disabled? At least it's less confusing for user and by default actual date is selected when datetimepicker is dispayed.
Jaroslav
Try this :
you can get just today's date as a DateTime using the Today property:
dtpDate.Value = DateTime.Today;
if you want to show only current date in your datepicker then use this code:
dtpDate.MinDate = dtpDate.MaxDate = DateTime.Now;
For more information
Refer this link
You can't do it on the picker. But you can fake it. Resize the dateTimePicker so it only shows the pick button. Then place it next to a textbox. In the onClose event you write the selected value to the textbox, and set the value of the dateTimePicker back to Today.
I have a grid with one row having a radio button list .
Based on this radio button list, a date is generated in another column.
If i allocate radio button for first time it works good and a date is created and so on...
but while I check another one from a different row after a week or two, the wrong thing happens.
I get a new date in all rows and it replaces the date created by the radio button two weeks back. :(
I use Telerik RadCalendar ASP.NET control. How I can in code reset selected date? (Set no selected Date)
From their site:
http://demos.telerik.com/aspnet-ajax/calendar/examples/programming/clientsideapi/defaultcs.aspx
unselectDate(date); //Takes a triplet representation of a date and if valid deselects it in the calendar.
unselectDates(dates); //Takes an array of triplets representing dates and if valid deselects them in the calendar.
First you can find what dates are selected with get_selectedDates()
Then put them in the unselect method.
var selectedDates = get_selectedDates();
unselectDates(selectedDates);
If you dont know what dates are selected maybe you can reload the calendar.
If you want to clear the selection server-side then this should work:
RadCalendarObject.SelectedDates.Clear();
is there any way to merge cells in a datagrid view or atleast can we show on the screen like some columns in the grid belongs to one group.
for example ill take three columns:
column1: year field(a drop down type)
column2: month field(a drop down type)
column3: date field(a drop down type)
all these three should be grouped to dateofbirth cell.
or is there any way to embed calendar component in the cell.. just like in some sites when we book some tickets we click on calendar icon & click the date and it will be captured in the corresponding field..
any ideas?
You can create your own DataGridViewCalendarColumn by inheriting from DataGridViewColumn, and a DataGridViewCalendarCell by inheriting from DataGridViewCell or DataGridViewTextBoxCell.
This isn't something I've done myself, but there are loads of tutorials online explaining how to create custom DataGridView columns. A google search may help.
what i have done for this is as follows:
i have taken a date time picker obj,which will be in invisible mode initially.
when i focus on the date of birth cell ,then date time picker will invoke(in a dialog) and will be visible for this focus time.
after selecting the date,the value will be inserted into the current cell.
if the focus is on the next rows and the corresponding cell then once again we follow the above step.