Home » WPFRSS

How to get cell values in a listview in C# WPF-urgent

how can I do following

 

 

int NumberofChildInALearningStory = SelectedchildInfoListView1.Items.Count;

 

for (int i = 0; i < NumberofChildInALearningStory; i++)
       {
          int ChildId = **Need to get SelectedchildInfoListView1  row[i] column[1] value**

      }

 

Can Any one please help me . This is urgent.

 

Thanks.

 

how can I do following

 int NumberofChildInALearningStory = SelectedchildInfoListView1.Items.Count;

 

for (int i = 0; i < NumberofChildInALearningStory; i++)
       {
          int ChildId = **Need to get SelectedchildInfoListView1  row[i] column[1] value**

      }

 

Can Any one please help me . This is urgent.

 

Thanks.

 

 

5 Answers Found

 

Answer 1

Is your listView data bound to some data model? Can you show XAML please?

 

Answer 2

 <ListView Grid.Column="1" Grid.Row="4" Grid.RowSpan="2" Margin="0,6,30,29" Name="SelectedchildInfoListView1" >
                                    <ListView.View >
                                        <GridView >
                                            <GridViewColumn DisplayMemberBinding="{Binding child_ID}" Width="60"/>
                                            <GridViewColumn  DisplayMemberBinding="{Binding family_name}" Width="auto"/>
                                            <GridViewColumn  DisplayMemberBinding="{Binding given_name}" Width="200"/>
                                           


                                        </GridView>
                                    </ListView.View>
                                </ListView>

 

data will added as follows

SelectedchildInfoListView1.Items.Add(new { child_ID = SelectedChildID, family_name = familyname, given_name = givenname });

 
 

Answer 4

It isn't common practice to work with ListView in that way. 

You should create separate entity (class) MyDataEntity with properties ChildID, FamilyName and GivenName. After that you should create ObservableCollection<MyDataEntity> EntitiesList and data bind ListView to this EntitiesList.

After that you will be able to enumerate EntitiesList in code, perform some magic and changes will be propagated to ListView due to binding mechanism.

If this doesn't help  or you need code sample, please let us know. If this is correct answer mark it as "Asnwer" please.


God bless you!
 

Answer 5

Hi Tillias,

Thanks for your advice; I managed to do the work as I want. But I would appreciate very much if you could send me some sample code for your proposal.

 

Thanks.

 

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter