Solved

Help with C# programming listbox and arrays

Posted on 2006-07-22
2
213 Views
Last Modified: 2010-04-16
I have three forms (frm1,frm2,frm3).  The first frm1 contains a listbox1,button1,listbox2, button2.
button1 opens up frm2, button2 opens up frm3.  

When i click button1, it open up frm2, frm2.listbox is filled with items to choose from, i need to select from frm2.listbox and return the items to frm1.listbox1.
when i click button2, it open up frm3, it takes the values from frm1.listbox1 items and is put in new sql search string, returns items to frm3.listbox1, user can now select which item he wants by clicking on button (>>) to move to frm3.listbox1.  

When he clicks OK button on frm3, frm3 closes, frm3.listbox1 is set equal to frm1.listbox2.

Need help with passing frm1.listbox1 and frm1.listbox2 items to frm3 and returning results to frm1.  
0
Comment
Question by:schen
  • 2
2 Comments
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 50 total points
ID: 17163216
to pass variable to a form what u could do is overload the form constructor


//constructor form 1
public void Form1(string AVariable)
{
}

//creating form 1

Form obj = new Form1(listbox.selectedvalue.tostring())

for retreiiving values from the form what u could do is
decalre a  variable in the form an set it to the value u want to return
//sample code below



Form obj = new Form1(listbox.selectedvalue.tostring());
//ShowDIalog()-----not Show()//Important
obj.ShowDialog();
//Value is the string decalre in the form which containds the value of the selected item
obj.Value


0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17163228
add to that above
//creating form 1
string AValue;
string AreceivedVariable;
public void Form1(string AVariable)
{
AreceivedVariable = AVariable;
//do whart ever u want to
}

event that u wnat to do
{
AValue = //the value u want
}

public string Value
{
get{return AValue}
}


//hope this works
Gautham
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now