I've found an answer that will let me set a row on a datagrid, although it seems a bit roundabout and hopefully unnecessary to do so - setting position of datagrid scrollbar
But before I go ahead and try to link my four DataGrids using this method (which I think is going to end up super messsy) I thought I'd ask - is there any way to neatly connect a scrollbar from one datagrid to another so that when I scroll down on Grid1 it'll scroll simultaneously on Grid2?
Assuming these grids will always have the same # of rows and columns
Or is there another way I should be constructing my views?!
I have a DataGridView with a DataSource and I want the data to be displayed on the entire width of the control with the auto-computed width of each column. The exception is the first one which should always have 100px.
I handled the Size event, I set always the fist column to have 100px and it works, but only if I manually resize the grid.
Is there any way I can do this automatically, right after the DataSource was set?
I tried to invalidate the control, I set (again) the autofill (and not only) flags of the grid, but no luck. Did anyone managed to do a similar thing?
When editing the columns, there is a property called AutoSizeMode. Im wondering why you are trying to handle it yourself. Just set all columns except the first one to AutoSizeMode = AllCells and then give your first column the width of 100px. Should do it shouldnt it?
Bonus: You can even set one of the columns to Fill in AutoSizeMode. Would look a bit better as your table is taking the full width.
If I missed the point please correct me...
I am looking for the best approach to getting the vertical height of a UltraWinGrid to change based on the number of rows it is bound to such that all rows are visible with no scroll bar. The intention is to stack several grids vertically in a scroll panel so only a single panel scroll bar appears when necessary rather than a scroll bar for each grid.
Basically the approach would depend on the current settings of your UltraGrid. Assuming that you have all rows with the same height than you could use something like the following:
int gridHeight = ultraGrid1.Rows.Count *ultraGrid1.DisplayLayout.Override.DefaultRowHeight + ultraGrid1.DisplayLayout.Bands[0].Columns[0].Header.Height + ultraGrid1.DisplayLayout.Bands[0].Header.Height + someConst;
Where the Column header and the Band header might not present into your layout. The
"someConst" refering to the "BorderStyleRow" property becasue the row border should also be taken into account when calculating the UltraGrid height. One more thing that you would like to consider would be the height of the GroupByBox if it is visible in your UltraGrid.
If this approach does not work for you please provide me more details of exact settings in your UltraGrid so I will try to assist you further with this matter.
The following post has a sample that gets the height of a UltraWinGrid and may be a good starting point for you:
http://blogs.infragistics.com/forums/p/18548/321187.aspx#321187
Say I have a Winform with 3 adjacent Textboxes, all within a Panel that covers the majority of the form. How can I configure it so that when I resize the form, the controls also resize, but do not bleed into each other? I've tried the different anchoring options, however the textboxes always tend to run into each other?
It's probably something really simple that i've missed.
Thanks.
One easy way to accomplish this is to put the three textboxes into a TableLayoutPanel that has 1 row and three columns.
Settings:
Set the width of each column to 33%
Set the anchor properties of the TableLayoutPanel to Top, Left, Right (or similar).
Set the Dock property of each TextBox to Fill.
Have a look at the TableLayoutPanel - you should be able to get the sort of behaviour you want using one of those with 3 columns and a text box in each one.
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.