Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:19:28+00:00 2026-06-04T01:19:28+00:00

This is how I add the 2 textblock to my listbox as an item

  • 0

This is how I add the 2 textblock to my listbox as an item

Dim StkP As New StackPanel
StkP.Name = "Stack"

Dim txtLine_1 As New TextBlock
txtLine_1.FontSize = 24
txtLine_1.Name = "txtLine_1"
txtLine_1.Text = "Units " + txtUnits_1.Text + ", Cost " + txtCost_1.Text

Dim txtLine_2 As New TextBlock
txtLine_2.FontSize = 24
txtLine_2.Name = "txtLine_2"
txtLine_2.Text = txtResult_1.Text

StkP.Children.Add(txtLine_1)
StkP.Children.Add(txtLine_2)

ListCompare.Items.Add(StkP)

But how can I retrieve the selected items values when I tap on listbox in vb.net?

I tried this code

Dim lbi As ListBoxItem = ListScore.ItemContainerGenerator.ContainerFromIndex(ListScore.SelectedIndex)
Dim stk As StackPanel = lbi.Content
Dim rs_1 As TextBlock = stk.FindName("lblScore_1")
Score_1.Text = rs_1.Text

But it is always returning the last input of “lblScore_1”

Any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:19:30+00:00Added an answer on June 4, 2026 at 1:19 am

    You’ll have to:
    – take the selected item;
    – cast it to a StackPanel;
    – access the children of the stackpanel;
    – cast the child items to TextBlocks and then read their properties as necessary

    Using databinding would make this much easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My xaml ... <ListBox Margin=6,35,6,6 Name=lbLayers SelectionMode=Extended > <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation=Vertical> <TextBlock Text={Binding
<ListBox x:Name=listBox> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Margin=10 > <TextBlock Text={Binding title}/> <TextBlock Text={Binding Description}/> </StackPanel>
I want to add this code: <link rel=stylesheet type=text/css href=css/global.css /> <!--[if lt IE
my listbox: <ListBox x:Name=listBox Grid.Row=2 FontSize=26 SelectionChanged=listBox_SelectionChanged ItemsSource={Binding SelectedSubGenre.PhotoCollection}> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush=BurlyWood BorderThickness=1,1,1,1
This post relates to this: Add row to inlines dynamically in django admin Is
I'm writing a COM add-in for Word, Excel and PowerPoint. This add-in has some
This question Add a version number to the title of a LaTeX document spurred
I add this class to library/My/Validate/PasswordConfirmation.php <?php require_once 'Zend/Validate/Abstract.php'; class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract {
I add this code in my activity public boolean onKeyDown(int keyCode, KeyEvent event) {
I add this tag to my asp.net page (aspx): <obout:Calendar runat=server ShowTimeSelector=true DateFormat=MM/dd/yyyy hh:mm:ss

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.