I'm using a System.Windows.Forms.ListView control in my application with its View property set to "List". However, the content ends up being in coloumns instead of a single coloumn (ie. There are only horizontal scrollbars instead of vertical ones). Is there any way to display the data in a single coloumn?
Yes if you are only displaying text, use the ListView in Detail mode and set the header style to None to remove the column headers. You will also need to ensure your single column fills the box.
Of course unless you need ListView's features you might be able to just use a ListBox instead.
Related
I have a WPF project with a DataGrid in my window and, initially, I just set its ItemsSource to a collection of objects, and the grid auto-generated columns, based on their properties. In that stage when starting the application I, as the user, could click a cell (in the user interface) and it would allow me to select/drag-select part of the text in that cell.
Now I disabled the auto-generation of columns and defined custom columns, binding them to select properties of said objects. And now clicking a cell just selects the entire cell and its entire contents. I've looked at all DataGrid and DataGridCell properties but don't see anything which would obviously alter this behaviour.
How can I set a manually defined DataGridTextColumn in the XAML to have the text content of its cells be partially selectable, instead of only being able to select the entire cell content?
The DataGridTextColumn is behaving the same whether it is autogenerated or not. Maybe you are setting IsReadOnly = True. That could be one reason for it to behave like you are describing. Otherwise, you have to provide us with code and data, that is showing your case.
I want to thank RolandJS, his answer made me realise I probably could inspect WPF controls' properties at debug time and that led me to the Live Visual Tree, seeing all properties are the same, which led me to the binding, which was mode = one way.
So, basically, the text in DataGrid cells can only be partially selected/drag selected if the binding is in a mode that allows changing the source, because that is what you are potentially doing.
I'm using a Telerik for WinForms RadGridView, I set the datasource to a custom list of objects and I enable the columnreordering. It works fine on the frontend, but if I go to select a row and read a value, it returns the vaule of the initial ordering not the actual one I see on the screen.
Nearly all 3rd party grid controls (not just WinForms) don't manipulate the underlying data source when sorts, column reordering, filter etc. are done on them. These are just display only features.
You should just read the column value via the key not index so that it will never matter what order the user puts a column in.
I have a simple combobox bound to a List where A has a property Key and a property Value.
The combobox binds fine and works except for one flaw. It has a large empty space at the bottom where there are no items (i.e they don't get highlighted on hover or any such thing, there are no extra items, it is just that there is an empty space). How can I get rid of it?
http://i.stack.imgur.com/2yN9r.jpg
This is most-probably because of the template of the ComboBox under your current theme. Try changing Windows theme to Aero or Luna (seems like now you have it set to Classic).
If that's the issue, then there's a way to "fix" it by using a custom template, but then you break consistency from user's point of view. You'd need to take it into consideration.
you need to change the Template of combobox and reset the popup height acordingly. check below.
http://msdn.microsoft.com/en-in/library/ms752094%28v=vs.85%29.aspx
Search for popup under the tempalte and add the minheight=0 into it.
In my ComboBox ItemsSource="{Binding MyItems..., if MyItems is a List, it will leave extra space. if MyItems is an ObservableCollection, the extra space goes away. This may due to a Microsoft bug that ItemsSource was not properly notify by MyItems change when it is a List object.
In the picture below I have defined a 6-row table layout and placed controls inside its cells, in one cell goes the Label, the other cell for the control its self (a text box for example )
The problem is caused by that field options radio box, it will make the cell so big so then the text box that is under "Preview Data Value" label, goes way below...
How do you suggest fixing this issue?
From my prior experience, I would not use the table layout at all. Instead I would set the anchors on each control to dynamically change with resize.
But if you insist on using the table layout, perhaps you should change the RowSpan attribute of the Preview Data Value cell, and have the label at the top with the text box underneath.
Another option would be to use a container like a GroupBox with a title Attribute that you can set to "Preview Data Value", put the text box in that container and set the "Dock" Attribute to "Fill". Then from the looks of it, you don't even need the last Row.
See this article on MSDN if you want to go totally nuts and implement your own drawing.
Make a seventh row and have the option group span two rows.
I have a DataGrid that is showing some data via a PagedCollectionView with one group definition. I have created a Style for the corresponding DataGridRowGroupHeader under which I have added a ControlTemplate containing an additional TextBlock and a spacing Rectangle. I would like to bind the widths of these controls to the widths of particular columns, but I am struggling to get this working. I would also like to bind the Text property of the TextBlock to a value.
I tried binding the widths via the Width property of a Rectangle in resources but this didn't work (possibly because the Rectangle was never drawn and therefore didn't calculate it's layout).
However, I believe both sets of bindings can be performed with some use of one or more ValueConverter implementations, but I was wondering if there was a better way. Can any of this be achieved through the definition of a ControlTemplate?
After some trial and error I was able to customize my row group headers. The key to unlocking the solution involved both the RowGroupHeaderStyles property and the LoadingRowGroup event on the DataGrid.
By defining one or more styles for the groups, I was able to customize the control template to include additional named elements. I then used the event to gain access to those elements and either set or bind the relevant values to show the information I required. The only stumbling I had related to binding the size of controls, which I eventually worked around by saving a reference to each row and setting those sizes when it was necessary to refresh them rather than relying on bindings. This may be specific to my project so your mileage may vary.
Update
JDM asked how you get the controls to perform binding etc. in the LoadingRowGroup event handler. You can get the row header from the DataGridRowGroupHeaderEventArgs.RowGroupHeader property of the event arguments and then use the VisualTreeHelper to get the child controls of the header. Once you have the controls, you can bind to them in code as you would any other control.