|
I only gave you a small bit of code to give you an idea on how to solve this. You have to do the rest. It's really simple. Just break it down into steps like this...
1) First, create a member variable in form2 that'll hold a reference to form1.
2) Next, you need to be able to pass a form reference to form2. To do that, you need to create a method or property in your form2 class that'll take that reference.
3) Next, when you create form2 from form1, you need to pass form1's reference via "Me" to form2. This will use the method or property that you created in step 2. Something like the code I gave you.
4) Next, you need to add a public method to form1 that'll allow form2 to change form1's PictureBox.
|
|
|
|
|
the concept u listed is wat i done, y i didnt use ME because the form cannot be convert to the system.drawing.image itself.
unless u know the command on convert it.
The coding i post early actually is from my previous project on the older version or VB. It's working but in VB.net it's not working anymore, i dunno is it they change any of the method or not on controling the image funciton.
-- modified at 10:15 Sunday 19th February, 2006
|
|
|
|
|
pittybird wrote: i didnt use ME because the form cannot be convert to the system.drawing.image itself.
Of course a Form reference can't be cast to a PictureBox.Image. They are two very different classes. You need to pass the PictureBox.Image reference in Form2 over to the PictureBox.Image property in Form1. That's what this whole exercise is really about.
Now there are multiple ways to pass this image reference over. Having Form2 reference and control Form1 is one way to do it and I was hoping this would be the easiest approach for you.
Dave's approach (see his post below) is an even better solution because a child form really shouldn't have any knowledge of its parent form. It just forces you to know more about events and setting up event handlers. Although I must say that it would be good for you to learn this.
Hell, an even better approach would be to fully implement the MVC pattern and introduce a Model which stores all player data and raises events anytime this data has changed to be caught by Form1, Form2, or any other form you might have in the future. But we would be getting into design patterns here and I don't think you're quite ready for that yet.
-- modified at 17:17 Sunday 19th February, 2006
|
|
|
|
|
actually i'm still new to vb.net,not really much understand wat u talking about... mostly theories... thanks anyway.
|
|
|
|
|
Forms in VB.NET are handled very differently than they were in VB6. The proper way to do this is Form2 should never know anything about, nor depend on the existance of, Form1.
Expose an event on Form2 that passes an Image back to any subscribers. When you click on the picturebox on Form2, Raise your event so Form1 will receive the Image and do whatever it needs to with the image, like pit in its own picturebox.
Form2:
Public Class Form2
Inherits System.Windows.Forms.Form
Public Event NewImage(ByVal i As Image)
Private Sub PictureBox1_Click(blah, blah) Handles PictureBox1.Click
RaiseEvent NewImage(PictureBox1.Image)
End Sub
End Class
Form1:
Public Class Form1
Inherits System.Windows.Form2.Form
Private Sub Button1_Click(blah, blah) Handles Button1.Click
Dim newForm2 As New Form2
AddHandler newForm2.NewImage, AddressOf form2newimagehandler
newForm2.Show()
End Sub
Public Sub form2newimagehandler(ByVal i As Image)
PictureBox1.Image = i
End Sub
End Class
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 13:15 Sunday 19th February, 2006
|
|
|
|
|
THANKS you so much!!!~ it works~
|
|
|
|
|
We are porting an application from vb to vb.net. We are accessing a dll which is working fine in vb, but in vb.net it's not.
We need to pass a reference parameter to the function being accessed in the dll. This parameter is of type structure.
Pls can anyone guide how to pass a reference parameter to a structure type.
---Pravin.
|
|
|
|
|
I don't think so. Structure type cann't pass by ref.
It pass by value.
http://www.startvbdotnet.com/oop/structure.aspx
!alien!
-- modified at 1:27 Saturday 18th February, 2006
see also
http://www.codeproject.com/dotnet/Structures_VBNet.asp
|
|
|
|
|
we can pass structure type byref. but i don't know exactly how?
|
|
|
|
|
Just a guess:
Sub ValMethod(ByVal struct as SomeStructure(
'Here it's passed by value
)
Sub RefMethod(ByRef struct as SomeStructure(
'Now you can modify the structure because it's passed by reference
)
HTH!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
this doesnt work
is it possible to to make this work?
Dim oleCmd As New OleDbCommand("SELECT RecNum " & _
"FROM Serial_Table", oleCon)
With oleCmd
lRecNum = .ExecuteReader.Item("RecNum").ToString
End With
tnx in advance
|
|
|
|
|
"This doesn't work" isn't a good explanation of the problem. What's it doing/not doing?? What are you expecting the code to do?
Also, there not enough of the code to "get it to work" or diagnose the problem. What is lRecNum defined as? What are you trying to do with the data?
About the only thing we could do is rewrite it and guess what you're trying to get it to do.
Dim oleDbConn As New OleDbConnection(connectionString
Dim oleDbComm As New OleDbCommand("SELECT RecNum FROM Serial_Table", oleConn)
Dim oleDbReader As OleDbDataReader
oleDbReader = oleDbComm.ExecuteReader()
While oleDbReader.Read() = True
' What are you doing with this data??????
...something...oleDbReader.GetInt32(0)
End While
oleDbReader.Close()
oleDbConn.Close()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 22:22 Friday 17th February, 2006
|
|
|
|
|
i was only wondering if it could be done
since there is "item" in executereader
ty
|
|
|
|
|
If WHAT could be done? You still haven't explained what your trying to do...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
rephrase:
is it possible to retrieve a data without using a datareader? (aside from executescalar)
is was wondering coz i saw "Item" in executereader
Dim oleCmd As New OleDbCommand("SELECT FldName " & _
"FROM TableName", oleCon)
With oleCmd
variable = .ExecuteReader.Item("FldName").ToString
End With
tnx in advance
-- modified at 20:46 Sunday 19th February, 2006
|
|
|
|
|
There are many ways to read a recordset. But, I'm repeating myself....What are you trying to do with this data???????? This will have a large impact on how you read it!!!!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
honestly nothing
im only experimenting on the "item" i found in datareader
|
|
|
|
|
WHY DIDN'T YOU SAY THIS IN YOUR FIRST POST?!?!?!?!
Private Sub Button2_Click(blah, blah) Handles Button2.Click
Dim conn As New OleDbConnection("connectionString")
Dim comm As New OleDbCommand("SELECT * FROM MyTable", conn)
Dim dr As OleDbDataReader
conn.Open()
dr = comm.ExecuteReader(CommandBehavior.CloseConnection)
Dim ID As Integer
While dr.Read()
ID = dr.Item("TableColumnName")
End While
dr.Close()
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
coz i didn't see it relevant
need not shout though
asking nicely
question wasnt still answered
might not be possible to to use the "item" in executereader
without using datareader in retreiving data
variable = executereader.item("fldname")
tnx anyway
|
|
|
|
|
It works. I just showed you how to use it.
You saw the Item property come up because the ExecuteReader method returns an OleDbDataReader object, which is the thing exposing the Item property.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Guys!! Im trying to debug my Project in VB.NET 2005 having .NET Framework 2.0.
Im getting this weird Exception called MissingFieldException. It gives the following Message:
Field not found: System.Collections.Generic.KeyValuePair`2.Key'.
This is its Stack Trace if of Any Help:
at BTSharp.Client.TorrentDownloader.Seed()
at BTSharp.Client.TorrentDownloader.SeedingPoll() in C:\Documents and Settings\David\Desktop\BTSharp\2.0_source\btSharp\Client\TorrentDownloader.cs:line 817
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
PLZ if anybody has heard of this Exception or know how to tackle the Problem, Reply back. Thanx!!
Devraj Raut!!!
|
|
|
|
|
|
Trying to write a new service on our application server that sends and gets ftp files to a remote server via ftp.
written something like this in vb6 before but want to try .net since the framework is there.
Not the sure of the best way to set up the timer in .net? in vb6 i would attach a form with a timer and LOAD that form from the main. This would cause the service to fire on specific interval and check for new files.
Any recommendations? Can't even seem to get the LOAD frm to work.
thx
|
|
|
|
|
You should use the System.Timers.Timer[^] class.
Also, if you're making a Windows Service, then you should not be using forms.
-- modified at 16:18 Friday 17th February, 2006
|
|
|
|
|
Hi,
I'm trying to query some data into a listview.
When there is more than one row of data on the listview, how can I choose a specific row to be displayed into a new form?
-----------------------------------------
MyQuery1 = "SELECT Date, Author, Comments, Ratings FROM [books] WHERE [name] = '" & txtbooksname.Text & "' "
Do While Not rs1.EOF
Set anItem1 = lvwRvw.ListItems.Add(, , rs1(0) & vbNullString)
For m = 1 To rs1.Fields.Count - 1
anItem1.SubItems(m) = rs1(m) & vbNullString
Next m
rs1.MoveNext
Loop
------------------------------------------
example:
Row Date Author Comments Ratings
1 01/01/2005 aaa romance B-
2 01/02/2004 bbb advanture B+
3 01/02/2005 bbb advanture B
How can I get the details of row 2 to be displayed on a new form?
Thank you very much.
|
|
|
|