Search Results

Search found 125 results on 5 pages for 'listviewitem'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • Can't seem to be able to set ListViewItem.imageIndex

    - by TKL
    I have been scratching my head with this error for at least an hour, what the heck is wrong here? In a loop: if (selectedItems[x].ImageIndex == 3) { List<ListViewItem> dupes = CP.listCache.FindAll(delegate(ListViewItem item) { return item.Text == selectedItems[x].Text; }); if (dupes != null && dupes.Count == 1) dupes[0].ImageIndex = 0; } I can access the imageIndex, but not set it. ArgumentOutOfRange exception occurs.

    Read the article

  • How to use two templates for ListViewItem using WPF

    - by Gregor
    Hi, I would like to have a ListView that would have have items similar to Microsoft Outlook inbox with items arranged by Conversations (see the attached photo). An item can either be a simple textblock containing the topic of the conversation (on the photo this are the blue lines) or it can contain email information specified by the ListView's header. It would be best if the items with conversation topics would be push buttons so that emails inside that conversation could be shown or hidden by pressing this button. Any ideas how can I achieve this? Do I specify two ListViewItem templates? If yes, how do I tell in the code which template to use for each item? Any help will be GREATLY appreciated!! Regards, Gregor

    Read the article

  • C# - Hiding ListViewItem based on a filter

    - by fonix232
    I want to hide some items based on a text filter in a ListView. Basically the listview loads the items from a text file, and I don't want it to be read and/or written when the user searches the list. The search is done in a combobox's KeyDown event, but there is no "Visible" property of the ListViewItem. Is there any easy way to do this, WITHOUT re-reading the file? (as it is an XML file, and it could even contain thousands of items, it would be hard to search efficiently and even let the user use the application, as the search would take for minutes (mostly with the loading)).

    Read the article

  • Hiding ListViewItem based on a filter

    - by fonix232
    I want to hide some items based on a text filter in a ListView (WinForms). Basically the listview loads the items from a text file, and I don't want it to be read and/or written when the user searches the list. The search is done in a combobox's KeyDown event, but there is no "Visible" property of the ListViewItem. Is there any easy way to do this, WITHOUT re-reading the file? (as it is an XML file, and it could even contain thousands of items, it would be hard to search efficiently and even let the user use the application, as the search would take for minutes (mostly with the loading)).

    Read the article

  • How does ListView.ItemCollection.Contains() work?

    - by Inno
    Hi everyone, I'm copying ListViewItems from one ListView to another, sth. like: foreach (ListViewItem item in usersListView.SelectedItems) { selectedUsersListView.Items.Add((ListViewItem)item.Clone()); } If I want to use ListView.ItemCollection.Contains() to determine if an item was already copied I always get false: foreach (ListViewItem item in usersListView.SelectedItems) { if (!selectedUsersListView.Items.Contains(item) { // always !false selectedUsersListView.Items.Add((ListViewItem)item.Clone()); } } I did the following to solve my problem: foreach (ListViewItem item in usersListView.SelectedItems) { ListViewItem newItem = (ListViewItem)item.Clone(); newItem.Name = newItem.Text; if (!selectedUsersListView.Items.ContainsKey(newItem.Name) { // this works selectedUsersListView.Items.Add(newItem); } } So, it's ok that this solves my problem but I still have no idea why ListView.ItemCollection.Contains() doesn't work... How does ListView.ItemCollection.Contains() identify if an item already exists? How do ListViewItems have to be initialised that ListView.ItemCollection.Contains() (not ListView.ItemCollection.ContainsKey()) is able to identify them?

    Read the article

  • How to access empty ASP.NET ListView.ListViewItem to apply a style after all databinding is done?

    - by Caroline S.
    We're using a ListView with a GroupTemplate to create a three-column navigation menu with six items in each column, filling in two non-data-bound rows in the last column with an EmptyItemTemplate that contains an empty HTML list item. That part works fine, but I also need to programmatically add a CSS class to the sixth (last) item in each column. That part is also working fine for the first two columns because I'm assigning the CSS class in the DataBound event, where I can iterate through the ListView.Items collection and access the sixth item in the first two columns by using a modulus operator and counter. The problem comes in the last column, where the EmptyItemTemplate has correctly filled in two empty list items, to the last of which I also need to add this CSS class. The empty items are not included in the ListView.Items collection (that's just ListViewDataItems, and the empty items are ListViewItems). I cannot find a way to access the entire collection of ListViewItems after binding. Am I missing something? I know I can access the empty items during ItemCreated, but I can't figure out how to determine where the item I'm creating falls in the flow, and whether it's the last one. Any help would be appreciated, if this can even be done -- I'm a bit stuck.

    Read the article

  • Wpf ListViewItem Background binding to enum

    - by Christian
    Hi Guys I´ve got a ListView which is bound to the ObservableCollection mPersonList. The Class Person got an enum Sex. What i want to do is to set the background of the ListViewItem to green if the person is male and to red if the person is female. Thanks for the answers!

    Read the article

  • CheckBox ListView SelectedValues DependencyProperty Binding

    - by Ristogod
    I am writing a custom control that is a ListView that has a CheckBox on each item in the ListView to indicate that item is Selected. I was able to do so with the following XAML. <ListView x:Class="CheckedListViewSample.CheckBoxListView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d"> <ListView.Style> <Style TargetType="{x:Type ListView}"> <Setter Property="SelectionMode" Value="Multiple" /> <Style.Resources> <Style TargetType="ListViewItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListViewItem"> <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True"> <CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"> <CheckBox.Content> <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" /> </CheckBox.Content> </CheckBox> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Style.Resources> </Style> </ListView.Style> </ListView> I however am trying to attempt one more feature. The ListView has a SelectedItems DependencyProperty that returns a collection of the Items that are checked. However, I need to implement a SelectedValues DependencyProperty. I also am implementing a SelectedValuesPath DependencyProperty. By using the SelectedValuesPath, I indicate the path where the values are found for each selected item. So if my items have an ID property, I can specify using the SelectedValuesPath property "ID". The SelectedValues property would then return a collection of ID values. I have this working also using this code in the code-behind: using System.Windows; using System.Windows.Controls; using System.ComponentModel; using System.Collections; using System.Collections.Generic; namespace CheckedListViewSample { /// <summary> /// Interaction logic for CheckBoxListView.xaml /// </summary> public partial class CheckBoxListView : ListView { public static DependencyProperty SelectedValuesPathProperty = DependencyProperty.Register("SelectedValuesPath", typeof(string), typeof(CheckBoxListView), new PropertyMetadata(string.Empty, null)); public static DependencyProperty SelectedValuesProperty = DependencyProperty.Register("SelectedValues", typeof(IList), typeof(CheckBoxListView), new PropertyMetadata(new List<object>(), null)); [Category("Appearance")] [Localizability(LocalizationCategory.NeverLocalize)] [Bindable(true)] public string SelectedValuesPath { get { return ((string)(base.GetValue(CheckBoxListView.SelectedValuesPathProperty))); } set { base.SetValue(CheckBoxListView.SelectedValuesPathProperty, value); } } [Bindable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Category("Appearance")] public IList SelectedValues { get { return ((IList)(base.GetValue(CheckBoxListView.SelectedValuesPathProperty))); } set { base.SetValue(CheckBoxListView.SelectedValuesPathProperty, value); } } public CheckBoxListView() : base() { InitializeComponent(); base.SelectionChanged += new SelectionChangedEventHandler(CheckBoxListView_SelectionChanged); } private void CheckBoxListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { List<object> values = new List<object>(); foreach (var item in SelectedItems) { if (string.IsNullOrWhiteSpace(SelectedValuesPath)) { values.Add(item); } else { try { values.Add(item.GetType().GetProperty(SelectedValuesPath).GetValue(item, null)); } catch { } } } base.SetValue(CheckBoxListView.SelectedValuesProperty, values); e.Handled = true; } } } My problem is that my binding only works one way right now. I'm having trouble trying to figure out how to implement my SelectedValues DependencyProperty so that I could Bind a Collection of values to it, and when the control is loaded, the CheckBoxes are checked with items that have values that correspond to the SelectedValues. I've considered using the PropertyChangedCallBack event, but can't quite figure out how I could write that to achieve my goal. I'm also unsure of how I find the correct ListViewItem to set it as Selected. And lastly, if I can find the ListViewItem and set it to be Selected, won't that fire my SelectionChanged event each time I set a ListViewItem to be Selected?

    Read the article

  • What is the most efficient way to delete all selected items in a ListViewItem collection

    - by Andrew
    My user is able to select multiple items in a ListView collection that is configured to show details (that is, a list of rows). What I want to do is add a Delete button that will delete all of the selected items from the ListViewItem collection associated with the ListView. The collection of selected items is available in ListView.SelectedItems, but ListView.Items doesn't appear to have a single method that lets me delete the entire range. I have to iterate through the range and delete them one by one, which will potentially modify a collection I'm iterating over. Any hints? Edit: What I'm basically after is the opposite of AddRange().

    Read the article

  • WPF: ListView inside LIstViewItem: How to support button_click

    - by Bartek
    Hi I have problem with using buttons that are placed in the itemtemplate of the listview which is placed in the itemtemplate of the outer listview. I'll try to simplify the code to show only the idea. I have a objects collection which looks like this: Main object contains a list of innerObjects. Every innerObject contains a list of objects that contain some strings. mainObject listItem innerListItem string string innerListItem string string listItem innerListItem string string I set a mainObject as a itemsSource to the ListView. This listView has a ItemTemplate. This ItemTemplate contains some buttons and inner ListView. Inner ListView also has the item template that contains a button (deleteButton). Pressing this deleteButton I want to delete items (innerListItem) for which this button was created. I can use such functionality when I have a sigle listView. private void clearAndList_Click(object sender, RoutedEventArgs e) { DependencyObject dep = (DependencyObject)e.OriginalSource; while ((dep != null) && !(dep is System.Windows.Controls.ListViewItem)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) { return; } ANDconditionsList andList = (ANDconditionsList)ConditionsList.ItemContainerGenerator.ItemFromContainer(dep); orConditionsList.RemoveConditionsSet(andList); } I can't use the same functionality because I can only use the name of the ConditionsList which is the mail listview. The idea is to find the innerlistview and use it instead of ConditionsList, however I don't know if it will work. If anyone have some samples concerning using listview in listview or how to operate the button in a different way please help me

    Read the article

  • Load a Settings.settings into ListView?

    - by clefranc
    Hi, I've managed to save ListView items to a System.Collections.Specialized.StringCollection property settings using this LINQ one liner: My.Settings.Property1.AddRange(ListView1.Items.Cast(Of ListViewItem)().[Select](Function(a) String.Join(Convert.ToChar(Keys.Tab), a.SubItems.Cast(Of System.Windows.Forms.ListViewItem.ListViewSubItem)().[Select](Function(s) s.Text).ToArray())).ToArray()) Now, I want to do the opposite, ie load the ListView1 from the My.Settings.Property1. It's fairly easy to do using a For Each loop, but I wonder if someone can show me a similar LINQ query. The lines in My.Settings.Property1 looks like this (Tab separated): Word1 Word2 Word3 Word4 Word5 Word6 Original code is from this answer: http://stackoverflow.com/questions/2295068/show-listview-items-in-a-combobox

    Read the article

  • How to Focus on ListviewItem in WPF?

    - by Prashant
    I have ListBox in my application with Ten items, user can see five items at time. Sometimes I'm selecting items from code and setting focus. Selecting an item and focusing work perfectly when items are visible on Form, but for other non-visible items, I'm unable to set the focus (NOTE: after selecting it is visible to user). Can anyone help me please?

    Read the article

  • How to Identify a ListViewItem to Update a Single Row

    - by tunneling
    I have a ListView displays information about an object. When I click a ListView Item, I open an Activity that let's me manipulate parameters of the object held in the adapter. These parameters are updated and stored remotely. When I return to the ListView (via the back button), I want to update the ListView Item that I clicked originally by requesting the parameter values from the remote server. I am currently doing this up updating the entire ListView by clearing it and rebuilding it. How do I reference the ListView Item so that I can update the data for that item only? Thanks, Jason

    Read the article

  • reading excell file in vb.net

    - by Mark
    can anyone help me on how to know EOF of excel using vb.net? i have this code but it crash when i try delete the proceeding rows from row 6 to downward. my problem is, my code was still reading a null values of rows that i deleted in excel.. this is my code: Dim xlsConn As New OleDbConnection Dim xlsAdapter As New OleDbDataAdapter Dim xlsDataSet As New DataSet xlsConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & pathName & " ; Extended Properties=Excel 8.0") strSQL = "SELECT * FROM [Sheet1$]" xlsAdapter.SelectCommand = New OleDbCommand(strSQL, xlsConn) xlsDataSet.Clear() xlsAdapter.Fill(xlsDataSet) ListView1.Items.Clear() Dim listItem As ListViewItem For ctr As Integer = 0 To xlsDataSet.Tables(0).Rows.Count - 1 listItem = ListView1.Items.Add(xlsDataSet.Tables(0).Rows(ctr).Item("EmpNo").ToString) listItem.SubItems.Add(xlsDataSet.Tables(0).Rows(ctr).Item("EmpName").ToString) Next Can anyone help me to fix this bugs!

    Read the article

  • reading excel file in vb.net

    - by Mark
    can anyone help me on how to know EOF of excel using vb.net? i have this code but it crash when i try delete the proceeding rows from row 6 to downward. my problem is, my code was still reading a null values of rows that i deleted in excel.. this is my code: Dim xlsConn As New OleDbConnection Dim xlsAdapter As New OleDbDataAdapter Dim xlsDataSet As New DataSet xlsConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & pathName & " ; Extended Properties=Excel 8.0") strSQL = "SELECT * FROM [Sheet1$]" xlsAdapter.SelectCommand = New OleDbCommand(strSQL, xlsConn) xlsDataSet.Clear() xlsAdapter.Fill(xlsDataSet) ListView1.Items.Clear() Dim listItem As ListViewItem For ctr As Integer = 0 To xlsDataSet.Tables(0).Rows.Count - 1 listItem = ListView1.Items.Add(xlsDataSet.Tables(0).Rows(ctr).Item("EmpNo").ToString) listItem.SubItems.Add(xlsDataSet.Tables(0).Rows(ctr).Item("EmpName").ToString) Next Can anyone help me to fix this bugs!

    Read the article

  • Android ListView item highlight programmatically

    - by dhomes
    Hi all, I know it's been asked around but I haven't found quite the answer yet (new to Android so sorry about the ignorance) my app's launch Activity has an EditText (called searchbox) , a ListView (designations) and a Spinner (types) I use the EditText as a searchbox, I have to pass the string through a custom editing to make searching more flexible. After that I match that against the closest approximation I find in 'designations' and do designations.setSelection(j); As expected, this sets the desired item to the top of designations. But I can find a way to highlight it via code. NOW, i do know that if the device is in touch mode the highlighting of a selected item won't occur. So the last 4 lines of my searchbox's onTextChanged event are: designations.setFocusable(true); designations.setFocusableInTouchMode(true); if (match==true) designations.setSelection(j); if (st.length()==0) designations.setSelection(0); to no avail. now, i don't have any code on searchbox's afterTextChanged(Editable s); so could anyone give me a clue on this? regards ~dh

    Read the article

  • WPF: How to set column width with auto fill in ListView with custom user control.

    - by powerk
    A ListView with Datatemplate in GridViewColumn: <ListView Name ="LogDataList" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding LogDataCollection}" Background="Cyan"> <ListView.View> <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Event Log Information"> <GridViewColumn Header="Event Log Name" Width="100"> <GridViewColumn.CellTemplate> <DataTemplate> <l:MyTextBlock Height="25" DataContext="{Binding LogName, Converter={StaticResource DataFieldConverter}}" HighlightMatchCase="{Binding Element}" Loaded="EditBox_Loaded"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> ... </GridView> </ListView.View> </ListView> I have no idea about how to make column width autofill although I have tried a lot of way to walk up. The general idea for demo is : <ListView Name ="LogDataList" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding LogDataCollection}" Background="Cyan"> <ListView.Resources> <Style x:Key="ColumnWidthStyle" TargetType="{x:Null GridViewColumn}"> <Style.Setters> <Setter Property="HorizontalContentAlignment" Value="Stretch" > </Setter> </Style.Setters> </Style> </ListView.Resources> <ListView.View> <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Event Log Information"> <GridViewColumn Header="Event Log Name" DisplayMemberBinding="{Binding Path=LogName}" HeaderContainerStyle="{StaticResource ColumnWidthStyle}"> It works, but not accord with my demand. I need to customize datatemplate with my custom user control(MyTextBlock) since the enhancement(HighlighMatchCase property) and binding datacontext. How can I set up ColumnWidthMode with Fill in the word? On-line'in. I really appreciate your help.

    Read the article

  • Click in a ListView item changes status of elements inside the item?

    - by Antonio
    Hi, I don't know exactly how to explain this problem, but I'll try. I have a ListView with several items. Each item has inside a TextView and two ImageView. I want the ImageView change when I click on them, and I want to open a context menu when I press for a long time into the ListView item. For the ImageView, everything works properly. For the whole item, I can show the context menu after a long press, but my problem is that the ImageView changes as well when I am pressing the TextView, for example. Somo pieces of my code: ListView item: <TextView android:id="@+id/title" android:textColor="@color/black" android:maxLines="2" android:textSize="14dip" /> <ImageView android:id="@+id/minus" android:src="@drawable/minusbutton" android:adjustViewBounds="true" android:gravity="center" /> <ImageView android:id="@+id/plus" android:src="@drawable/plusbutton" android:adjustViewBounds="true" android:gravity="center" /> Drawable to change the status of the plus button: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/button_add_normal_disabled" /> <item android:state_enabled="true" android:state_pressed="true" android:drawable="@drawable/button_add_pressed" /> <item android:state_enabled="true" android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/button_add_active" /> <item android:state_enabled="true" android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/button_add_normal" /> I hope you understand my problem. I think that all the children of a view are affected by an event in the parent, but I am not sure. Do you have a solution? Thanks in advance

    Read the article

  • ListView item won't extend width to fill_parent

    - by slybloty
    I have a custom ViewGroup that inflates a ListView from an xml layout. The list item layout is inflated from another xml file. All of the views are set to fill_parent. The ListView fills its parent, but the ListView items don't. I've tried putting the ListView in a LinearLayout and assigning weight to it. Tried RelativeLayout as well. Also, I've built the ListView programmaticaly, without using the xml layout. Even changed the LayoutParams before adding the view to the ViewGroup. I've also taken in consideration these posts as well: Width of clickable area in ListView w/ onListItemClick, In Android, how can I set a ListView item's height and width?, Android Listview width prob. Any ideas to why the items don't extend to fill width? And how to extend them? MyViewGroup class: public class MyViewGroup extends ViewGroup { public MyViewGroup(Context context, AttributeSet attrs) { super(context, attrs); generateMyViewGroup(); } private void generateMyViewGroup() { ListView main = (ListView) View.inflate(getContext(), R.layout.layout_main, null); main.setAdapter(new MyAdapter(getContext())); this.addView(main); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { this.getChildAt(0).layout(l, t, r, b); } } ListView xml layout: <?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="3dp" android:background="#77000000" android:cacheColorHint="#00000000" android:divider="#00000000" android:dividerHeight="0dp" android:drawSelectorOnTop="false" android:scrollbars="vertical" > </ListView> ListView item layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_main_category" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/mainBackground" android:gravity="fill_horizontal|center_vertical" android:orientation="vertical" > <TextView android:id="@+id/main_category" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:paddingBottom="7dp" android:paddingLeft="20dp" android:paddingRight="5dp" android:paddingTop="20dp" android:text="test" android:textColor="@color/mainCategory" android:textSize="15sp" android:textStyle="bold" /> </LinearLayout>

    Read the article

  • ListAdapter to modify the datasource (which is an arraylist)

    - by dusker
    Hi Everyone, here's a problem that i've run into lately: I have a listview with a custom adapter class, the adapter takes in a listview and populates the listview with elements from it. Now, i'd like to have a button on each row of a listview to remove the item from it. How should i approach this problem? Is there a way to remotely trigger a method in the activity class and call notifydatachanged() method on the adapter to refresh the listview? thanks in advance for your help and some code snippets if possible best regards peter

    Read the article

1 2 3 4 5  | Next Page >