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
narasiman rao
NA
519
771.8k
how display the selected month date in datagridview usingc#
Feb 13 2013 8:07 AM
DateTime dt1 = dateTimePicker1.Value;
dt1 = new DateTime(dt1.Year, dt1.Month, 1); // get first day of selected month
DateTime dt2 = dt1.AddMonths(1); // get first day of next month
int numDays = (dt2 - dt1).Days;
if (dataGridView1.RowCount < numDays)
{
dataGridView1.RowCount = numDays;
}
int row = 0;
while (dt1 < dt2)
{
dataGridView1.Rows[row].Cells[1].Value = dt1.ToString("dd/MM/yyyy");
dt1 = dt1.AddDays(1);
row++;
}
I work out your code, but when i run i get the error as follows;
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
the above error occurs in below line as follows;
dataGridView1.Rows[row].Cells[1].Value = dt1.ToString("dd/MM/yyyy");
please help me.
Thanks & regards,
rao.
Reply
Answers (
2
)
add to many values to datagridview combox
C# Errors.....Need Help!!