473,327 Members | 1,892 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,327 software developers and data experts.

How to use an object to travel data from one form to another

Hi,
I have two forms.Both having DatagridView.There are two comboboxes to filter the record from Database and fill in Datagridview.My requirement is when all the data is populated in DataGrid after selecting the comboboxes and when the user clicks on Delete.
The comboboxes and Datagrid on second form should have the same values as that was on first form.The names of my Comboboxes and Datagridview are same on both the forms
Below is the code my Datagrid view getting populated in First Form.
Expand|Select|Wrap|Line Numbers
  1.  Sub GetData(ByVal StrQuery As String)
  2.         If CBMedium.Text <> "" And CBClass.Text <> "" Then
  3.             DGVStudRecord.Rows.Clear()
  4.             con = DBConnect()
  5.             cmd = New SqlCommand(StrQuery, con)
  6.             dr = cmd.ExecuteReader
  7.             If dr.HasRows Then
  8.                 While dr.Read
  9.  
  10.                     DGVStudRecord.Rows.Add(dr(0), dr(1), dr(2), dr(3), dr(4), dr(5))
  11.                 End While
  12.             End If
  13.             con.Close()
  14.  
  15.         End If
  16.     End Sub
Please suggest how can i populate my datagrid in second form by using the Data populated in Datagrid of Firrt Form
Sep 7 '11 #1
2 1374
Hi,

I think creating a singleton class will help you hold values across forms. Check singleton pattern under creational pattern in design patterns. If need a online help, go to dofactory site, there it is explained nicely by GOF
Sep 23 '11 #2
Thanks mate for your reply.I think i was not able to explain u what i wanted.I have got a simpler way to do it.I just want that some data that is populated on form1 should be displayed in form2 as well.
This was my grid for Form1.I want the same data also on form2 when user clicks a certain button on form1.So i can simply assign these values to Datagrid in form2.
Expand|Select|Wrap|Line Numbers
  1.   DGVStudRecord.Rows.Add(dr(0), dr(1), dr(2), dr(3), dr(4), dr(5))
  2. form2.DGVOnForm2.Rows.Add(dr(0), dr(1), dr(2), dr(3), dr(4), dr(5))
  3.  
Frnds i think this is the simplest way to do it.
Sep 23 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: luu duong | last post by:
I know this is probably easy but here is the details. I have an asp page that is not inside a frameset. I want to post data to another asp page that is inside a frameset. So firstpage.asp has...
11
by: Vanessa | last post by:
Hi, I would like to know whether there's any way for me to pass an object by reference to another form? Regards Vanessa
5
by: Vanessa | last post by:
I have a question, is that any other way to retrieve data from another webpage besides using XML object? Because I am using XML object now but give me so much problems. If I used...
4
by: Andrea De Santi | last post by:
How can I redirect to another page with form data? In asp Classic I write: <form ... action="filename">...</form> and in then target page I write <%=request.form("fieldname")%> ..... but in...
1
by: john m | last post by:
Hello, I used the very cool xsd.exe program to generate classes from an existing schema. Now I am reminded of the old vb6 data form wizard which could generate data aware forms from classes....
5
by: Peter Olcott | last post by:
I created an object that requires access to another objects data, yet have found no good way to pass this data as a parameter because the member function that requires this data must be a binary...
4
by: Peter Afonin | last post by:
Hello, I have a form with several buttons, and I need to post this data to several different applications. In ASP.NET 1.1 it was quite easy - I just used HTML controls (text or hidden), then...
9
by: sandykumar | last post by:
hiii i want to transfer data from one site to another site. there is a form in site www.abc.com and this form is similer to form of site www.xyz.com. data filled in form of site...
7
by: Boki | last post by:
Hi All, I can't pass data to another form: in form2: private void button1_Click(object sender, EventArgs e) { Form1 form_copy = new Form1();
3
by: liadmz | last post by:
Hi, I am currently learning c#.net. the following command to retrieve data from another component on another form: to change it's value and stuff.. In vb.net I would use lblMax.Text =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.