I realized something annoying when using a data grid view control. When I try to set the cell's height by setting the RowTemplate height property to fit more records on the grid, the vertical scroll bar stops acting nicely and the grid doesnt display all the records (it only shows the records that fit on the available space plus one extra record!) until you resize the columns or something like that! But if I set the AutoSizeRowsMod property to AllCells the grid displays all the records, however the cell's height is now too big for me!
Is there a way to control the cell's height and still show all the records on the DGV? Does it even make sense that it's behaving this way?
Thanks
Related
I want to scroll a grid horizontally. By default, it scrolls pixel by pixel. I want to scroll column by column. Simply, a column should shift to left/right 100% or 0%. Shouldn't scroll by a fraction of it's width. (This applies to the first column visible to the user at the moment).
What I want is a way to do "snappy" scroll.
How can I get this done?
To scroll grid's content, use the GridView.LeftCoord property. To access boundaries of columns, the GridViewInfo.ColumnsInfo collection will be helpful. You can see how to implement this feature in the How to implement scrolling by columns in the grid e2481 example.
I have a WPF datagrid where certain rows will be disabled. In addition to disabling the cell contents, I'd like to present to the user some text that overlays the row with an explanation such as "Row disabled due to ...". Basically the same effect of having a label control with a lower z-order sitting directly in front of the datagrid row's cells.
If cell text spillover was possible (like in Excel), I could create a text column of 0 width with the message, then let the message runover through the neighboring cells. But to my knowledge this type of text spillover isn't possible in the datagrid.
If your rows have fixed height, you could add a another transparent datagrid on top of the other datagrid. The transparent datagrid would have one column which would show the disabled explanation. Simple but hacky solution.
The proper way would be to use adorners.
I've got a Silverlight user control that contains a datagrid. The datagrid is bound to an ObservableCollection. The user control is displayed in a popup window that I show in response to some event in another control
There are about 80 objects in the collection, and I've set a fixed height of 400 on the datagrid, so only about 20 items can be shown at one time, and the vertical scrollbar should be shown, with a thumb size occupying about 1/4th of the control height.
However, what's actually happening is that the scrollbar occupies almost the whole control height; maybe 95% of it. The datagrid displays the first 20 items. When I click on the scrollbar down arrow, the scrollbar moves down a little to occupy the bottom 95% of the scroll area, and the datagrid displays the last 20 items.
It gets weirder. If I move over the items in the grid and scroll down using the mouse wheel, then the items scroll correctly and I can view the whole list, although the scrollbar remains the same size.
And then, if I close the popup and reopen it, the scrollbar now appears with the correct height and it works correctly.
Finally, if I just show the control directly on the page, and not in a popup, it works fine.
What's going on here?! Has anyone else run into this problem? Help!
Update: The problem seems to be the way that I'm showing the popup. For various reasons, I had to implement the popup display in a somewhat tricky way, and it's this that's causing the trouble.
I recoded this, removing some crufty stuff, and the problem went away; see my update. This isn't really a solution as such, but I wanted to close out the question for the record.
I currently have a GridView inside a ListView.View. The GridView columns will far exceed the width of the screen, so there will always be horizontal scrolling.
What I would like to do is to have certain columns always remain on the screen regardless of scrolling. So the first x columns from the left are frozen (ala Excel), and the rest can scroll.
It does not need to be dynamic/user selected--I know in advance which columns need to be frozen.
Is this possible?
Quick and dirty solution would be to use two listviews next to each other. Left one would be for the frozen columns and right one would have horizontal scrolling enabled. If you need vertical scrolling you can wrap both listviews in a scrollviewer.
I'm using a DataGridView in VB.Net in VS 2005. The issue is, when there are rows that exceed the width of the DataGridView, the horizontal scroll bar doesn't appear (the ScrollBars property is set to "Both"), but an ellipsis appears at the end of each row that is too long. I don't want the ellipsis, but the horizontal scroll bar. The vertical scroll bar works as expected when the number of rows exceed the height of the DataGridView. Any ideas on how to resolve this?
I have tried setting numerous related properties (changing the AutoSizing property of the DataGridView, Resizability of the Row Template, made sure that no Columns were Frozen) to no avail.
Thanks!
Set the AutoSizeMode of the problematic column to AllCells.
This will resize the column header and force it to go out of the visible area thus displaying the horizotal scrollbar.
I just had the same issue. I had set the last column to Fill, so it was always resizing to fit to the visible area.