Reputation: 1441
I have a form which contains a DataGridView. When the grid is populated it has around 2500 rows. Because of this a ScrollBar is placed on the right to navigate. This is default.
I have just programmed my form to resize the DGV. When the user resizez now, the ScrollBar dissapears. You can still navigate with the mouse wheel.
I want to get the scroll bar back.
Does any one know why this happens?
for (int i = 0; i < languageTabs.TabCount; i++)
{
Control[] ctrls = languageTabs.TabPages[i].Controls.Find(languageTabs.TabPages[i].Name + "Grid", true);
DataGridView dgv = ctrls[0] as DataGridView;
dgv.Size = new System.Drawing.Size(this.Width - 40, this.Height - 125);
dgv.ScrollBars = ScrollBars.None; // doesnt seem to do anything
dgv.ScrollBars = ScrollBars.Both; // doesnt seem to do anything
}
Abve is the rezizing loop for all tabs and DGV's.
Upvotes: 0
Views: 1360
Reputation: 1441
// resize the dgv and columns
for (int i = 0; i < languageTabs.TabCount; i++)
{
Control[] ctrls = languageTabs.TabPages[i].Controls.Find(languageTabs.TabPages[i].Name + "Grid", true);
DataGridView dgv = ctrls[0] as DataGridView;
dgv.SetBounds(14, 14, this.Width - 70, this.Height - 150);
}
The problem was the ammont I was sizing by ( -70 , -150). Before it was too little so the scroll bar was hidden to the right.
Upvotes: 1