I have a DataGridView on Window form which is populated with 30 columns and thousands of rows.
ScrollBars property is set to Both, but still horizontal scroll bar is not visible. even I am unable to scroll with arrow key from keyboard.
I tried it by setting ScrollBars property to Horizontal as well, but that does not make any difference.
Any suggestions please?
Thanks
Well Guys, its sorted out.
I am answering my own question; it may help someone in future.
one of the columns has Frozen property set as True. which should be false for all columns.
Now ScrollBar is working absolutely fine for me.
Cheers
I know this has already been resolved, but I've come across another reason why this could happen, so thought I'd add it as an answer in case someone else has the same problem.
If your form has a DataGridView that is docked to fill the form, and the form also has a status bar, then depending on the order they're created, the status bar can hide the DataGridView's scrollbar. To fix this, right click on the DataGridView, and select "Bring to Front".
When I encountered this annoying problem, it was due to the AutoSizeColumnsMode property of the DGV that was set to Fill
I fixed it by changing that property to AllCells, but any other value will work. It works even if the DGV is docked and I have multiple docked panels, and the first column is Frozen.
The docking.Fill of the DGV is a little buggy.
It happens when you have multiple docked panels, toolbars, etc.
More common when you're creating your columns at runtime.
The control thinks it is wider than its container and the Horizontal scrollbar does not spawn.
Frozen, autosize, brint to front and the other remedies mentioned don't always work.
The most reliable workaround is to Dock.Left and set the DGV's width at run time.
This way the DGV doesn't get confused about how wide it is.
i had the similar problem. What I did was, check each of your Datagrid columns and set the Frozen to "false". Hope that helps.
I was having this irritating problem. I had already created the DataGridView on my Form and am setting all the databinding and properties setting in the .CS file.
I just commented the line in my code behind file (.cs) i.e.
gvTblContent.AutoSize = true;
You need not to set the AutoSize property, horizontal and vertical scrollbars will be provided by default otherwise you can use :
gvTblContent.ScrollBars = ScrollBars.Both;
I had a similar problem, not due to the frozen property, but most likely to DataGridView bugs, after I added some rows programmatically. After reading this answer to another question I solved using:
dgv.PerformLayout()
after adding those rows, just before dgv was about to be shown.
In my case i just used ANCHOR Top, Bottom, Left, Right instead of DOCK Fill.
Try it.
I had a similar issue but inside SplitContainer. None of the above worked, but use all four anchors instead of Dock.Fill of DataGridView.
I also meet this problem. It's a stupid situation in my case.
Please check the position/size of DataGridView whether out of the form.
I had the same problem and found that my dataGridView was slightly larger than the form that it was in. I adjusted the size to fit in the Form and it worked!
Hope this helps!
Multiple show/hide columns on my side was causing the same issue. Had to add
dataGridView1.ScrollBars = ScrollBars.Both; after I process all the columns and rows in the datagridview
Nothing of the above helped before that
1. No Frozen Columns
2. Form load has dataGridView1.ScrollBars = ScrollBars.Both;
3. No Status bar
I too had this problem in VS2015 on a winform.
The winform has a table layout split into 4 rows, 1 column. Into the rows I place panels for placing other controls except the DataGrid row which is in the last row. The DataGrid is set with Dock to fill. The form also has a Status bar at the bottom, for future use.
What I found is that the status bar blocked the scrollbar as mentioned previously.
I added another row to the table layout but that would display a large blank space at the bottom of the form both at run time and design. Resizing the form did not resolve either. I tried setting the row height of the table layout but it did not work. I tried 1 pixel, 5 pixels etc. no change. In the end I gave up and removed the Status bar, wasn't using it for anything anyway.
I had a DataGridView sitting inside a cell of a TableLayoutPanel, and neither scroll bar was showing up on the DataGridView. I think the size of the DataGridView also wasn't being managed properly with the DataGridView being docked to fill a cell of the TableLayoutPanel. I didn't have any frozen columns.
I was able to fix it by placing the DataGridView inside a Panel, and setting AutoScroll=true on the Panel, to let the Panel manage the scrolling. I docked the panel to fill inside the cell of the TableLayoutPanel, and docked the DataGridView to fill inside of the Panel.
In my case Scroll bar didn't appear until when I realized the above frozen column state and read-only. I have done frozen columns for read-only column as well the one editable column in my dataGridView. When I remove frozen=false for editable column, the horizontal bar appear.
I set some first columns frozen to true it(H_bar) still works. But I set frozen = true to a invisible column (column.visible=false), it gone.
I had the same problem with DataGridView inside a tableLayoutPanel.
None of the above helped me.
It turns out that the column in the tableLayoutPanel in which the DataGridView is is set to AutoSize.
The solution is to set the tableLayoutPanel columns to actual value or percent.
All your frozen columns should fit within the form.
Otherwise horizontal Scrollbar does not show up.
If there is no horizontal Scrollbar then make your form wider until you see your last frozen field and then Horizontal Scrollbar will magically appear.
There one more thing you could check on. The "Enabled" property of the GridView control should be set at "true".
DataGridView Properties:
Fixed my problem, but it was none of the above.
In my situation, I was creating my entire form at run-time. Each DataGridView was Dock.Fill inside a TableLayoutPanel. You don't have to specify row or columns for a TableLayoutPanel if there is only going to be one, and it should be 100%. Doing this however breaks DataGridView. Fixed my problem by simply adding the row 100% definition.
in the video below you can see how my buttons behave when i try to resize the window after anchoring them. My application does not have an exist button for some reason either, could not find a solution online and have no clue on how to fix it for the time being. Sorry for potato quality....
https://youtu.be/6WY_19Qdy4c
Did you know that sometimes anchor cannot fix of what will you want to achieve?
Instead of anchoring you can use tableLayoutPanel?
The only properties of tableLayoutPanel is Dock = Fill;
After that you can now add columns and rows in the table and button inside the cell, it will automatically resize your button.
Add a tableLayoutPanel set Dock to Fill
Click tableLayoutPanel
Edit Rows and Columns (Add Column or Rows Change Absolute to Percent it should be 50%)
Press OK
If you want to span Rows and Columns click the control inside the Cell and find ColumnSpan and RowSpan in the properties
I have a WinForm project with a tab control container and several tabs. On 1 tab, I have 2 grids, one on top of the other. The grids stretch all the way across the form when fully maximized or when floating (minimized but not hidden). That part works exactly how I want it to.
However, I want the grids to size proportionally on the vertical axis. I cant find a way to set a % for the height of the grid. Is there some other trick to achieving this? Any tips on what property or combination that I might need to set or investigate? Sorry, I know not much to go on, but any help would be appreciated.
Follow below steps, it will work fine.
Place tablelayoutpanel control in tabcontrol.
Set rows and columns for tablelayoutpanel using the "Edit Rows/Columns"
If you have 2 datagridviews only in this tabcontrol, then set row count 1,column count 1.
Set column1 with Percentage 100 ,row1 with 50%, row2 with 50%
Set tablelayoutpanel dock property to fill.
drag and drop datagridview1 to tablelayoutpanel row1 and set the dock property to fill.
drag and drop datagridview2 to tablelayoutpanel row2 and set the dock property to fill.
I'm using Visual Studio 2008.
I have a DatagridView which contains four columns named "Visibility", "Tipe","Name","Info".
All the column header texts are entirely visible but the texts inside the cells of the last column
are not entirely visible. I want an horizontal scrollbar to see all these texts.
The DatagridView is docked to fill to a panel and the property ScrollBars is set to Both.
I see the vertical scrollbar but not the horizontal scrollbar. I've tryed to use this suggestion like this:
ScrollBar in DataGridView
or to set MinimumSize of the DatagridView but without getting any positive results.
How can I display the horizontal scrollbar?
Thank you
One of the column must have a frozen property set to true, try setting it to false
It may be that your Frozen column property is set to true. This was I believe an option in vs2008. This will stop the horizontal scrollbar from showing.
Fill mode and frozen =false does not work for me.
Set Fill to AllCells and frozen was defaulted set to false works (VS 2015).
I've create a c# winforms form,
It has a bunch of labels positioned and a flowlayoutpanel.
on certain occasions i set one of the labels and the flowlayoutpanel to visible =false.
As a result i want all labels beneath them to be pushed up - at the moment there is a gap where they were.
Also, I'd like the flowlayoutpanel to grow and shrink depending on the number of items it has.
at the moment it is just the size i set it to be in the designer.
please can you help with these 2 issues.
Thanks
If I got you correctly, I would suggest using a TableLayoutPane with two rows. The top row will contain a docked panel with all the controls that may be hidden. The bottom row will contain a docked panel with all the rest.
Set the top row's SizeType to AutoSize and the bottom row's to 100%.
When you want to hide the controls, set the top panel's Visible property to false. Now, because the top row is AutoSized it will shrink to nothing, causing the bottom row to "jump" up.
The TableLayoutPanel does the pushing. Maybe you can use that if there is no better answer in next time.
First problem:
You may use some simple panels to divide your form, give them the dock.fill property. when you'll hide a panel programmatically, the other panels will fill the empty space left.
Second problem:
You have to set the Autosize property to true.