I am populating a ListView with a DataTable from the code behind. The problem is, that the ListView is becoming too long with too many items.
I am wondering, how can I make this:
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Into this:
Item 1 Item 4
Item 2 Item 5
Item 3 Item 6
Maybe I'm overlooking something, but I can't seem to find the answer.
Please not that I want to keep it in one ListView, so I'm not looking to split the items and put them into multiple ListViews.
Solution: Use a DataList in stead of a ListView. See Tim's answer.
Use a DataList instead. It has a RepeatDirection and RepeatColumns properties. The former would be RepeatDirection.Vertical and the latter 2 in your case.
Gets or sets the number of columns to display in the DataList control.
Related
Hello I'm searching throught internet for hours but still I can not find the answer. (or I just don't know how to ask)
I need a simple numerical order of items in listbox fe. I am adding every 3rd items to listbox from txt file.
When I have this in txt file:
Acc 4
name4
pass4
Acc 5
name5
pass5
I'll add to listbox only Acc4 and Acc5
And now when I select some item in listbox I want to know which one is selected but I don't want fe.: Acc6 (is selected) but I want to know Acc6is 3nd one in listbox (then order is 2)
PS: sorry for my end and thx for help
If you are looking for the index of the selected item in a listbox try
{listBoxName}.SelectedIndex
This will give you the index (0 based) of a selected item. https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.listbox.selectedindex?view=netframework-4.7.2
If you want the item try
{listBoxName}.SelectedItem
This gives the currently selected item https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.listbox.selecteditem?view=netframework-4.7.2
I have a ListView with 9 columns and an unknown number of rows.
In two different columns, the user shall be able to click (or double-click) on a subitem and I need to know which of these two subitems in this row was chosen.
So I need to know either which SubItem of a ListView has been chosen or in which column it was.
Thank you!
Tom
In my model I have a near-infinite list of items. Let's assume the items are -9999, ..., 0,+1,+2,+3, ...., +9999, with items having an increment of 1 between them.
I would like to display a list of 5 of the items, centered on an "item of interest". The "item of interest" changes by 1 at a time, either up or down, at any time. When it changes I would like the control to do an animated pixel by pixel "scroll" until it centers on the new item of interest. The user can not scroll, so the list is always centered on the "item of interest"
Assume the item of interest is 3, then the displayed list should look as follows:
1
2
3
4
5
Now the item of interest changes to 4, so after the scroll animation the displayed list should look as follows:
2
3
4
5
6
I'm using c# and WPF. Are there existing controls out there that do this, open source or commercial?
Assuming that each item is located in a Control, you can call the BringIntoView method, that will make the containing ScrollViewer scroll to the desired item.
Here is a similar question, using the MVVM pattern : mvvm how to make a list view auto scroll to a new Item in a list view
I have a repeater with an ItemTemplate contains a CheckBox, TextBox
My repeater represents a check list plus a TextBox to put a comment to each item I select from the list.
Now, I've a page for editing an existing shopping cart in my database and it uses this repeater to enable the user to update his list. So I need to update the List with the previous selected values from the database. I can't think of a simple logic or way to access only the repeater's items that are on the previous list ...I'm thinking about trying to access each item that's in my database only instead of looping and looping.
I know It's really confusing so I'll just put it in a more illustrative way:
Database View
Items
=======================
ID Name
--- -----
1 Banana
2 Apple
3 Strawberry
4 Orange
ShopCart_Items
========================================
ItemID ItemName CartID Value
------- --------- ------- ------
2 Apple 1 1
4 Orange 1 2
2 Apple 2 2
PageView
First the repeater is populated with all the items that I have in my 'Items' table and no boxes check or anything.
Then I choose a specific cart (say cartId = 1) to edit, and here's what I'm really confused on how to do:
Now the repeater will have like 15-20 items, so I need to access just the items that the user choose on the current cart (cartId = 1) that the user want to edit, so he could know what did he choose and start choose new values, check/uncheck CheckBoxes, etc.
I'm sorry for all this long question, but I'm really confused should/can I access each item directly or what logic do you advice me to use ? ..Thanks =)
I believe that you have mix two different entities in a one repeater - an orders and order items.
In my opinion the better approach is to place two repeaters onto the page: the first one for displaying orders and the second one for displaying order items for the selected order. This way you may use simple SqlDataSource controls for both repeaters and add a ControlParameter to the datasource used for retrieving order items depending on current order selection in the first repeater.
I am using a listview with 6 items per page. When I choose an item from the 6 items it should take me to a page with 3 items per page BUT the selected item (on previous page) as FIRST item in the list on the new page. Basically how do I set which items shows first in the listview? Is that a property?
There is no property for setting the first item. If you are using a datasource, the items will be displayed in the order they occur in the datasource, which is generally the order that the database returns them.
If you need a different ordering, you can code a loop through your datasource and assign the items to the ListView manually.