Hi Manu,
You can use the GetColumnDisplayRectangle method of the DataGridView and the column width to determine wether the clicked cell is partially displayed. If so, use the HorizontalScrollingOffSet property to scroll the DataGridView. The following is a sample:
dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
Rectangle entireRect = this.dataGridView1.GetColumnDisplayRectangle(e.ColumnIndex,false);
Rectangle visiblePart = this.dataGridView1.GetColumnDisplayRectangle(e.ColumnIndex, true);
if (visiblePart.Width < entireRect.Width)
this.dataGridView1.HorizontalScrollingOffset += entireRect.Width - visiblePart.Width;
else if(visiblePart.Width < this.dataGridView1.Columns[e.ColumnIndex].Width)
this.dataGridView1.HorizontalScrollingOffset -= this.dataGridView1.Columns[e.ColumnIndex].Width - visiblePart.Width;
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.