Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Auto map time and room to datagridview C#

Auto map time and room to datagridview C#

Auto map time and room to datagridview C#

I want to look at the datagridview to know what time of the meeting is as shown in the picture. after selecting the start time and end time and choose the room
will automatically fill in the datagridview and have the background as shown. but the following code does not get that position, hope everyone can help.

private void selectAreaColor()
string starttime1 = cboStarttime.Text;
string stoptime1 = cboStoptime.Text;
// Get the start time and end time inputs and the selected meeting room
DateTime startTime =DateTime.ParseExact( starttime1,"HH:mm",null);
DateTime endTime = DateTime.ParseExact(stoptime1,"HH:mm",null);
string selectedRoom = cboRoom.SelectedItem.ToString();

// Loop through the rows in the DataGridView and find the matching row
foreach (DataGridViewRow row in grdMeeting.Rows)
if (row.Cells[0].Value.ToString() == selectedRoom)
// Loop through the columns and compare the start and end times with the time slots
for (int i = 1; i < grdMeeting.Columns.Count; i++)
DateTime columnTime = DateTime.ParseExact(grdMeeting.Columns[i].HeaderText, "HH:mm", null);
if (startTime == columnTime || endTime == columnTime)
//MessageBox.Show("Are you OK ");

grdMeeting.CurrentCell.Style.BackColor = Color.Blue;//Can't get the location to create the background




Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close