Click here to Skip to main content
14,699,107 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
My applcation is in WPF.i want to add value in each column of list view.I have write code
which add the same value in all row.
i want to add different value in different column.
plz help me..
thanks
i am putting my code..
istview.xaml
<Grid>
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="23*" />
           <ColumnDefinition Width="255*" />
           <ColumnDefinition Width="0*" />
       </Grid.ColumnDefinitions>
       <ListView Height="114" Margin="10,10,9,0" Name="lstView" VerticalAlignment="Top" Grid.ColumnSpan="2">
           <ListView.View>
               <GridView>
                   <GridViewColumn Header="ID" Width="40"></GridViewColumn>
                   <GridViewColumn Header="User Name" Width="100"></GridViewColumn>
               </GridView>
           </ListView.View>
       </ListView>
       <Label Margin="59,0,76,70" Name="label1" Height="28" VerticalAlignment="Bottom" Grid.Column="1"></Label>
   </Grid>




listview.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace listview
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lstView.Items.Add("vishal");
          // lstView.
        }
    }
}
Posted
Updated 29-Apr-11 20:16pm
v3
Comments
Ankit Rajput 30-Apr-11 1:53am
   
I have updated my asnwer. Please check it

1 solution

Hi Vishal,

Please go through with these articles

Using The ListView, Part 1

Regards
AR
   
v2
Comments
vishal_h 30-Apr-11 1:16am
   
thanks ankit but i am developing this in WPF and i could not add System.Form namspace which is not possible so what can i do in WPF to add valu in xaml.cs file.
Ankit Rajput 30-Apr-11 1:44am
   
ok

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900