|
-
Aug 4th, 2004, 01:42 PM
#1
Thread Starter
Hyperactive Member
Accessing datagrid on different form
Ok, i got 2 forms, a startup form with a datagrid on it and another form that needs to be able to access the datagrid on the first form. I can't simply call the form like i can in vb6... because i have to access the actual object instance of the form. So i attempted using sub main as my startup item and then having it initialize the main form, however this didn't work. The form would appear and close a second later. I then decided to try making an datagrid object in a module and setting it to the datagrid on the form in the form load event. This didn't work either. It gave the error: "No value at index 0" when i tried accessing the datagrid object from the second form. I just started using visual basic.net.... today...., so i don't know exactly what i am doing.. ahaha. Is there a way to access the startup form from another form? or is there another way i should try doing this?
My monkey wearing the fedora points and laughs at you.
-
Aug 4th, 2004, 02:09 PM
#2
I wonder how many charact
(simplifies problem)
I have 2 forms:
Form1 has a datagrid
Form2 needs to access the datagrid on Form1
How do i access the datagrid from Form2?
-
Aug 4th, 2004, 02:12 PM
#3
I wonder how many charact
Put a public property on Form1
VB Code:
Public Property MyDataSource As DataSet
...
End Property
That would give you complete access. You simply share the underlying datasource (whether its a dataset or arraylist).
-
Aug 4th, 2004, 02:25 PM
#4
Hyperactive Member
Hi Arrow, no panic, surely we can solve that problem!
I think your way of using sub main is good. You can also pass your object to the second form as a byref (I know, it works also Byval , but it's a question of clear coding) parameter in the constructor (New) procedure. I think you have to post some code.
Why a form appear and disappear a second later? You have to post your sub main code and the code around where you instance the second form (what happens to the first one? Is it closed or hidden?). I hope I'll be able to help you, if I'll have all informations I need! Bye!
Live long and prosper (Mr. Spock)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|