Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Display items created in listbox on mainform textbox

Posted on 2013-01-22
3
Medium Priority
?
259 Views
Last Modified: 2013-01-28
Hi.

I have created a mainform that will contain a combobox with 3 options, radiobuttons, textbox and listbox.  When the user selects Listbox, a new form is opened and will allow the user to add items to a listbox.  Now, I want to save those items to an array, such that when the user clicks the close button on that subform, a textbox must appear on the mainform, listing all the items, (seperated by a comma), in that textbox.

Any idea how to store my listbox items in an array and pass it back to my mainform to be listed in a textbox?
0
Comment
Question by:Jasmin01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38804940
Given that you will display the items in a text box, you do not need an array. Just append the items together separated by comma and use a public variable on main form or directly access the textbox on mainform to post this string.
0
 

Author Comment

by:Jasmin01
ID: 38804959
This is what I have so far:

Behind the combobox with "List" selected :
ElseIf cboSelType.SelectedIndex = 3 Then
            Dim formListbox = New frmListbox
            Me.Visible = False
            formListbox.Show()

Open in new window

Behind the Save button of the Listbox form:
 Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
        IO.File.WriteAllLines("listbox.txt", lstAddItems.Items.Cast(Of String).ToArray)
    End Sub

Open in new window

What would I need to do?
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 38805449
Just do:
ElseIf cboSelType.SelectedIndex = 3 Then
            Dim frmLB As New frmListbox
            If frmLB.ShowDialog() = DialogResult.Ok Then ' <-- code STOPS here until "frmLB" is dismissed
                Dim values() As String = frmLB.lstAddItems.Items.Cast(Of String).ToArray
                ' ... we are in the main form still, do something with "values" ...
                TextBox1.Text = String.Join(",", values)
            End If

Open in new window


In frmListbox, you dismiss the dialog by setting DialogResult:
Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
    Me.DialogResult = DialogResult.Ok
End Sub

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question