473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Communicating Between 2 Forms..

hello again, i have another question... i am writing a program with 2
windows forms...

first form have a search button and several text buttons to list the data
loaded from an sql database

second form just have a listbox that shows the search results in the
listbox..
i want to let user select from the second form's listbox and show the
results from the first form. how can i "post" te selected items name to the
first form without creating another form? the only way i find is like this:

first form:

public void listitems(string selecteditem)
{
dataview.rowfilter = "username = '" +selecteditem +"'";
}

and in the second form:

private void listBox1_DoubleClick(object sender, System.EventArgs e)

{

Form1 f = new Form1();

f.list(listBox1.SelectedItem.ToString());

f.Show();

}

but that makes my program show several "form1" ' s in my program and thats
something i really dont want to happen.. so is there a way to "post"
variables between forms like asp.net do?

p.s: i cant write replies from outlook express. so i thank you from here
for spending your time to respond and helping. have a good day.
Nov 16 '05 #1
1 2189
Hi,

Instead of creating public function in form1 create a public function in
form2. When user selects the value from the list box in the 2nd form just
hide the form2 and than call that public function from form1 and dispose the
second form(if needed)

I think this would help :)


"Serdar C." <se*****@interaktif.gen.tr> wrote in message
news:ef**************@TK2MSFTNGP12.phx.gbl...
hello again, i have another question... i am writing a program with 2
windows forms...

first form have a search button and several text buttons to list the data
loaded from an sql database

second form just have a listbox that shows the search results in the
listbox..
i want to let user select from the second form's listbox and show the
results from the first form. how can i "post" te selected items name to the first form without creating another form? the only way i find is like this:
first form:

public void listitems(string selecteditem)
{
dataview.rowfilter = "username = '" +selecteditem +"'";
}

and in the second form:

private void listBox1_DoubleClick(object sender, System.EventArgs e)

{

Form1 f = new Form1();

f.list(listBox1.SelectedItem.ToString());

f.Show();

}

but that makes my program show several "form1" ' s in my program and thats
something i really dont want to happen.. so is there a way to "post"
variables between forms like asp.net do?

p.s: i cant write replies from outlook express. so i thank you from here
for spending your time to respond and helping. have a good day.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin | last post by:
This is probably a very easy one but I just can't put my finger on the communicating events name:- I have a MDIform with a couple of child forms. The child forms scroll vertically at run time...
13
by: Craig | last post by:
Hey all, Here's the situation: - two websites, one on domain1 and the other on domain2 - domain1 opens a new window which is a javascript app from domain2 - domain1 needs to communicate with...
4
by: ReMEn | last post by:
How can I call a function located in Form1 while in the scope of Form2? I've tried Form1.MyFunction() but I get a compile errors. Any ideas? Thanks.
3
by: Stan | last post by:
Hallo, I have developed an application in MS Access 2000 (Polish version) under MS Windows XP prof (also Polish). Now I would like to run this code on MS Windows XP EN and MS Access XP EN. I have...
1
by: Serdar C. | last post by:
hello again, i have another question... i am writing a program with 2 windows forms... first form have a search button and several text buttons to list the data loaded from an sql database ...
1
by: TGF | last post by:
Hello, I have a little dilemma (At least it is to me). I have two classes, Class A and class B, where Class A contains the UI thread and class B contains another thread. I want to be able to...
6
by: AMeador | last post by:
I have a form where a user will check boxes next to items that have been completed. They will click a button on the form to mark the items as completed. When they do this, I will have the 'parent'...
3
by: Mike Grainger | last post by:
Good Day: I am attempting to reference the value in a dropdownlist in the contents frame from the main frame and use it for filtering od a dataview. I get object is null. Any help on...
6
by: PaulN | last post by:
I need to instantiate a class (Class1) in the startup form (Form1), set some of Class1's properties then open another form (Form2) and have it read Class1's properties and set the remainder of...
2
by: Jasper Jones | last post by:
I have a main form which has a list of items from a table on my database. If I click one of these items it brings up a second form which lets you edit the details for that item. If I change an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.