0

Hey

I'm trying to manage some processes

So ive created a listview, the first column contains the name of the processes, the second should contain the id of the process, but I honestly cannot figure out how to get it working, making the "ListViewItem" control, but its not really working as i thought, any idea on how i could solve this :(?

Regards
-Jazerix

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by Sravanthi Ch
Featured Replies
  • You have to pass a value to the 1st subitem of the listView, like that: [CODE] string name = "SomeName"; int id = 2; ListViewItem lvi = new ListViewItem(); lvi.Text = name; lvi-Subitems.Add(id.ToString()); listView1.Items.Add(lvi); [/CODE] If you want to insert in a specific row, you have to create a loop … Read More

2

You have to pass a value to the 1st subitem of the listView, like that:

string name = "SomeName";
int id = 2;
ListViewItem lvi = new ListViewItem();
lvi.Text = name;
lvi-Subitems.Add(id.ToString());
listView1.Items.Add(lvi);

If you want to insert in a specific row, you have to create a loop of the listView`s rows:

for(int i = 0; i < listView1.Items.Count; i++)
{
    //same code here as abouve
}
0

may i ask, how do i associate a contextmenustrip to the selected item in my listview? :D

0

Hi,

Check this..

<ListView Name="MyListView" >
     <ListView.ContextMenu>
             <ContextMenu Name="MyContextMenu">
                 <MenuItem Name="MyMenuItem1" Header="Menu Item1" Click="MenuItem_Click"/>
                 <MenuItem Name="MyMenuItem2" Header="Menu Item2" Click="MenuItem_Click"/>
          </ContextMenu>
      </ListView.ContextMenu>
      <ListView.View>
      <GridView>
            <GridViewColumn Header="ID" Width="Auto" DisplayMemberBinding="{Binding ID}" />                                    
            <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path = Name}" Width="Auto" />
      </GridView>
     </ListView.View>
</ListView>

>


Hope this helps..


Regargds,

Sravanthi Ch

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.