TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rahul agarwal
NA
118
649
how to add calendar in datagridview column
Sep 14 2017 4:15 AM
hi,
I am doveloping software for desktop solution on visual studio 2010 using c# language. But i have a problem to add a calendar in datagridView column.
i am waiting for u anwser.
pls rply me ASAP.
thanks..
using this code
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
// If any cell is clicked on the Second column which is our date Column
if (e.ColumnIndex == 1)
{
//Initialized a new DateTimePicker Control
oDateTimePicker = new DateTimePicker();
//Adding DateTimePicker control into DataGridView
dataGridView1.Controls.Add(oDateTimePicker);
// Setting the format (i.e. 2014-10-10)
oDateTimePicker.Format = DateTimePickerFormat.Short;
// It returns the retangular area that represents the Display area for a cell
Rectangle oRectangle = dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
//Setting area for DateTimePicker Control
oDateTimePicker.Size = new Size(oRectangle.Width, oRectangle.Height);
// Setting Location
oDateTimePicker.Location = new Point(oRectangle.X, oRectangle.Y);
// An event attached to dateTimePicker Control which is fired when DateTimeControl is closed
// oDateTimePicker.CloseUp += new EventHandler(oDateTimePicker_CloseUp);
// An event attached to dateTimePicker Control which is fired when any date is selected
oDateTimePicker.TextChanged += new EventHandler(dateTimePicker_OnTextChange);
// Now make it visible
oDateTimePicker.Visible = true;
}
}
private void dateTimePicker_OnTextChange(object sender, EventArgs e)
{
// Saving the 'Selected Date on Calendar' into DataGridView current cell
dataGridView1.CurrentCell.Value = oDateTimePicker.Text.ToString();
}
void oDateTimePicker_CloseUp(object sender, EventArgs e)
{
// Hiding the control after use
oDateTimePicker.Visible = false;
}
its not working..
Reply
Answers (
1
)
what is the ans for the below objective type qus in mvc?
Type of c# application