简体   繁体   中英

Horizontal Scrollbar is not visible on DataGridView

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) ie

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.

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!

In my case i just used ANCHOR Top, Bottom, Left, Right instead of DOCK Fill.

Try it.

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.

I had a similar issue but inside SplitContainer . None of the above worked, but use all four anchors instead of Dock.Fill of DataGridView .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM