Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15122

VS 2013 How do I modify an specific element in my listbox?

$
0
0
Hello,
I am fairly new to VB.NET and I am building a Windows Store app in VB.Net.
in my program I load an XML file, which I then display in a ListBox.

Which I have not yet succeeded, is modify an specific element in the listbox.
The user selects an element in the list box, which is then displayed in 5 different text boxes (name, country, region, grape, alcohol).

After that, the user adjusts a value in 1 of the text boxes. This value must then be found in the listbox and adjusted.


At the moment the search and adjustment does not yet work. I'm trying to search the list for the value of the textbox using LINQ, but I keep getting an empty value back.


I've been working on this for a while now but I don't see it anymore.
Can someone help me on my way?


What I have tried:


Code:

Dim query = From Wine In xWines.Descendants("Wine")
            Where TBCountry.Text = Wine.Attribute("Country").Value _
            And TBName.Text = Wine.Attribute("Name").Value

        Select WName = Wine.Attribute("Name").Value,
              WCountry = Wine.Attribute("Country").Value


        For Each Wine In query
          Wines.Element("Name").SetValue(TBName.Text)
          Wines.Element("Country").SetValue(TBCountry.Text)
     
        Next Wine



Example of the XML file:


Code:

<Wines>
<Wine Name="Canapi Grillo" Country="Italie" Region="Sicilie" Grape="Grillo" Alcohol="12"/>
<Wine Name="Miopasso Fiano" Country="Italie" Region="Sicilie" Grape="Fiano" Alcohol="13"/>
</Wines>


Viewing all articles
Browse latest Browse all 15122

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>