I have two problems with a ListView I am using.
My ListView is set as ListViewView.View = List and I am adding a few items to it, via ListView.Items.Add(string).
The first one, I notice that for text items that are wider than the width of the ListView itself there is no horizontal scroll bad, and I can't seem to find a way to enable it.
The second is that to select an item I need to select click on part of the item itself, rather than the line the item is in. In other words, if I have an item with a really small length, I can't click anywhere on the line to select it, I have to click on it.
Here is an the code I have an what I am seeing:
listView1.Items.Add("aaaabbbbccccddddffffeeeegggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz");
listView1.Items.Add("a");
As you can see from the image above there are no scroll bars and the length of the text on Index[0] is much wider than the width of the ListView
Likewise on Index[1] where the text is just a single a, to select it I have to click directly on top of the a rather than anywhere else in the line.
Is there a way of fixing these two problems easily?
Also the reason why I'm using a ListView is because I want to add images to the items.
Thanks.
For your second problem just set the FullRowSelect to true in properties or you can do listview1.FullRowSelect = true;
Related
I am currently developping a slideshow viewer that should be able to display all of its images in a grid like display. However, this display has the following requirements :
It should show all items without having to scroll;
It should be able to handle resizing well (like the Grid control does);
I am using a ListBox, with its ItemPanel set to either WrapPanel or UniformGrid, but they didn't met the requirements : Wrap Panel isn't resizing its items to fill all available space ; UniformGrid gets closer to the desired result, but still leaves an empty space at the end of the last row (ie it should only add a row when it can entirely fill it)
I am therefore looking into a way of setting an UniformGrid so that there's no "blank" left at the end.
As an example, let's say I have three items in my collection, and the actual room to fit them all on one row ; the grid will still creates another row for the third one.
I am also open to solutions for that problem involving other controls, as long as they have a similar behaviour on item resizing and still show all of their items at once.
Thanks
We finally decided to go with a simple wrap with a variable width between items and to just deal with having to scroll if there's too many items.
In a checkedlistbox control in C# winforms I can add items into it, however the items will be placed under each other even when the height is smaller than the items combined.
My question is;
Can I "split" the checkedlistbox so you can see everything without having to scroll?
So when the left side is full, it will start on the other half of the checkedlistbox.
What you are looking for is CheckedListBox.MultiColumn property.
I'm looking for a control that can hold a list of text items.
For example:
Item 1
Item 2
Item 3
When I add a new item to this list (Item 4 for example), I want the new item to appear at the bottom of the list, and the other items to shift up 1 position. So in this example, adding Item 4, will mean that Item 1 will disappear from the list.
The reason I have not just gone with a listview is because I want the items to scroll up, like an animated transition if that makes sense?
Is there something out there that can do this, or should I be writing my own control?
EDIT: An example of a web based control:
http://buildinternet.s3.amazonaws.com/projects/totem/index.html
EDIT 2: I'm also not after a horizontal marquee control.
You can do that with a ListBox. It isn't exactly a beautiful solution, but adding to its collection and then either scrolling or setting the selected index to ListBox.Items.Count - 1 works.
[Edit:] Oh right, animated. I believe the scrolling is animated if you set the selected index, but I doubt it will be satisfying if you are going for nice graphics.
I have created a CheckedListBox control with 4 elements in C#. Multicolumn is set to true. As soon as I make the height of the control small enough to contain only a single row, I can no longer interact with the control with the cursor when I execute the program. If I make the height one unit (pixel?) larger, so that there are 2 columns of 2 rows, behavior returns to normal.
When the cursor cannot interact with the CheckedListBox, I can still tab to it, toggle between its elements with the arrow keys, and check/uncheck elements with the space bar. I just cannot use the cursor.
Looks like a bug to me... I'm experiencing the same thing occasionally. It happens when (1) the CheckedListBox is 1 row high, and (2) the items in it extend ANY past the right edge of the control. If the control is made a little wider, the mouse clicking works again. (You can test that theory by anchoring the CheckedListBox Left/Right and resizing the form. Now it works, now it don't.)
Seems like setting the width to be total column width + 4 also works.
There is a minimum width such that all columns are fully displayed that must be met before you can interact with it via mouse cursor.
My problem is that I have a databinded ItemsControl with some data presented in a list and user can scroll up and down.
When adding new items to the list (i.e. user refreshes the list), the scroll position moves according to however many new items there are. Is there a way to keep the scroll position upon adding new items?
Thanks
If you have a look at the TombStone Helper project on Codeplex in the ListBoxTombstoner.cs class [1] you will find code which allows you to get at the underlying ScrollViewer for the listbox and get its VerticalOffset property.
You will then be able to manipulate this property however you want - either adding to it if you want the scroll position to move as you add items, or keep it the same.
[1] http://tombstonehelper.codeplex.com/SourceControl/changeset/view/e737b2a34421#TombstoneHelper%2fListBoxTombstoner.cs
Try to set IsSynchronizedWithCurrentItem="True" on the ListBox
Assuming that all items are of a fixed height you should be able to adjust the the ScrollOffset after the addition-being sure to take the number of added items into consideration.