I am binding a datagridview to a list of objects. One of its columns is a checkbox which is supposed to represent a bool property, the rest are comboboxes and textboxes. Everything is fine, but the checkbox cell is appearing as blank !
Also, when I assign the columntype, each type appears twice in the list e.g. DataGridViewCheckBoxColumn
DataGridViewCheckBoxColumn? why is that happening ?
I just had to increase the row height from 17 to 18 !! Figured it out by chance
change AutoSizeRowsMode=AllCells
Related
I am working with a windows form that will hold multiple instances of the DataGridView class. When I attempt to select cells in one grid I seem to get a highlighted cell in the other grids. The extra highlighted cells will not be copied if I use CTRL+C, but it is misleading. I assume this is do to some issue with the on click event.
Here is a picture of what it looks like:
Per the discussion in the comments, OP's issue was resolved by removing the bind to the same object via the DataSource property.
Here is an example image of a datagridview.
I'd like to make this row based so instead of a cell being selected I'd like the entire row to be selected. The rows/cells are read only so no cell needs to be edited. also I like to remove the leftmost side where the > is.
(Crappy image found via google)
myGrid.RowHeadersVisible = false;
myGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
You can set these properties in code as above, or via the designer. RowHeadersVisible is under the Appearance section. SelectionMode is under the Behavior section.
For the full row select part of the question, the DataGridView control has a property called SelectionMode. Set that property to SelectionMode.FullRowSelect.
Not sure if the leftmost part can be removed but you can changed the width of it to 1 or 2 pixels. Cannot remember what it is called but there is a property on the DataGrifView control that controls the width of that first 'row indicator' column.
I have a collection of objects which I am trying to bind to a DataGrid. When the collection has a lot of objects in it, it works fine. When the collection is empty, however, I see a blank row in the DataGrid, however, I cannot edit it. When I bind it to a collection which has an empty list, then two rows appear, and it is possible to edit the second row with the first empty, even though I have validation. I have tried both an ordinary List<>, and an ObservableCollection<>.
How can I make it so that either the DataGrid can enter into an empty list, or that the DataGrid won't let the user enter into the second blank row?
For what its worth, I did figure out what my problem was. Well, I fixed the glitch, but I am not at all sure why it worked.
In the Binding field of the DataGrid, I had Mode=TwoWay on. I thought this was needed, as I wanted the grid to go back to the data, and vice versa. Turns out, removing this fixed the problem.
I have a WPF application with DataGrid
The DataGrid contains 4 columns with a checkbox template column on the first column
the problem is when i check some of the checkbox on the items, the checkbox would got reset when i sort a certain column. For example i check the checkbox on the row 2 it gets unchecked when i sort the datagrid.
been searching for similar case like this for a while but haven't seen one
Thanks,
DataGrid has to redraw rows when sorted. When redrawing it accesses the properties for each item in the bound ItemSource. If the checkbox repaints "unchecked" that tells me that it isnot bound or not properly bound or bound one way
I have a combobox in WPF that I add items to at run-time (via a data binding to a List). I'd like to set the height of the dropdown box dynamically so that all (or most) of the items show. Unfortunately it seems that the height of the dropdown is set once and cannot be dynamically altered. It always seems to be the same size.
Is there some relatively straightforward to adjust the dropdown height?
Yes, I've tried setting it after adding the items to the combobox. In the debugger it looks like the new value is there. However, when I open the dropdown, it drops down to a size of its own choosing. I've tried exaggerating the MaxDropDownHeight and have even set it to "Auto" to no avail.
The property MaxDropDownHeight is a dependency property, on the combo box that controls the height of the drop down list. Since it's a dependency property, it's value can be set dynamically.
Have you tried setting this value?
MaxDropDownHeight="Auto"
For me, the issue was that ComboBox dropdown had height of 95 pixels regardles of the amount of items.
My data source for the ComboBox was a Collection<>, but after changing it to ObservableCollection<>, the ComboBox dropdown opens showing all items.
Now also the MaxDropDownHeight property works just fine.
Ref: This comment in here Make the dropdown of a combobox be shorter?
Set your ComboBox's Style={x:Null} to ensure that you don't have a style issue affecting the drop-down panel size.