Click here to Skip to main content
15,943,588 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generalits solved Pin
manni_n25-Feb-07 1:45
manni_n25-Feb-07 1:45 
GeneralRe: multiple forms [modified] Pin
TwoFaced25-Feb-07 8:21
TwoFaced25-Feb-07 8:21 
GeneralRe: multiple forms Pin
JUNEYT25-Feb-07 11:49
JUNEYT25-Feb-07 11:49 
GeneralRe: multiple forms Pin
TwoFaced25-Feb-07 14:59
TwoFaced25-Feb-07 14:59 
Generalacceptable answer Pin
JUNEYT25-Feb-07 22:59
JUNEYT25-Feb-07 22:59 
GeneralRe: acceptable answer Pin
TwoFaced26-Feb-07 13:53
TwoFaced26-Feb-07 13:53 
GeneralYour solution is not appropriate! Pin
JUNEYT26-Feb-07 23:22
JUNEYT26-Feb-07 23:22 
GeneralRe: Your solution is not appropriate! [modified] Pin
TwoFaced27-Feb-07 9:36
TwoFaced27-Feb-07 9:36 
B Journey wrote:
The most practical way should be the set the caller form as parent form and then in 2nd form redirect user to parent form.


That's exactly what I did in the first example. Form2 excepts a caller, 'the parent', so it knows who to talk to. The thing that seems to bother you is the 4 lines of code it takes to do that. Sorry, I just don't consider that a "bunch of coding". It's a pretty simple straighforward solution. Not to mention the fact that you could actually create your own extended form class with this code in it. Then whenver you need a form like this you would inherit from this class. You would have no need to write that code ever again Smile | :)

Also there is another way. There always seems to be another way, huh. The show method is overloaded and excepts an 'owner' form. You could pass your forms instance when you call the show method. Every form has an 'Owner' property. You could then access the caller through this property from form2. One thing to note about an owned form is that it will minimize whenever the owner minimizes and restore whenver it's restored. This may be desired, and in your case it doesn't even matter because the owner would be hidden and couldn't be minimized. So for example
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim frm As New Form2
    frm.Show(Me)
End Sub
Form2 could then use the code Me.Owner.Show to show it's parent.
B Journey wrote:
This cannot be applied for forms because a form instance can be triggered from different procedures at same time. Therefore, sticking with creation time is not appropriate. Think about two timer components. Each timer shows the same form in every second because the each timer works independently.


I'm not sure why you think this (the code I posted last time) can't be applied to forms. It most definitly can, and does work just fine. The reason I showed the creation time was to clearly demonstate the same instance of the form was being shown whenver you called Form1.show or Form2.show. The point of the code was to demonstrate that in vb.net there is already a built in way to show a form without having to worry about creating a new instance or tracking the old instance. Form2.Show will create a new instance for you if one doesn't already exist, and if it does that same instance will be shown (sound familiar). It should because that's exactly what I did in the original post I made. Now if you meant it wasn't appropriate because you thought each timer needed to show a different instance of the other form then yes of course that code woulnd't be appropriate. As I've stated from the begining different situation call for different solutions.


-- modified at 15:44 Tuesday 27th February, 2007
Questionwhat is 192 bit encryption Pin
onrivman24-Feb-07 22:01
onrivman24-Feb-07 22:01 
AnswerRe: what is 192 bit encryption Pin
Guffa25-Feb-07 1:49
Guffa25-Feb-07 1:49 
Questionevents and delegates in vb.net Pin
Pankaj Garg24-Feb-07 19:31
Pankaj Garg24-Feb-07 19:31 
AnswerRe: events and delegates in vb.net Pin
JUNEYT25-Feb-07 0:50
JUNEYT25-Feb-07 0:50 
QuestionReferential classes in vb.net Pin
Pankaj Garg24-Feb-07 19:27
Pankaj Garg24-Feb-07 19:27 
AnswerRe: Referential classes in vb.net Pin
JUNEYT25-Feb-07 0:59
JUNEYT25-Feb-07 0:59 
GeneralRe: Referential classes in vb.net Pin
amaneet25-Feb-07 1:54
amaneet25-Feb-07 1:54 
GeneralRe: Referential classes in vb.net Pin
JUNEYT25-Feb-07 2:33
JUNEYT25-Feb-07 2:33 
QuestionAuthenticaton mode(Desktop application) Pin
Pankaj Garg24-Feb-07 19:07
Pankaj Garg24-Feb-07 19:07 
Questionoption explicit and option strict Pin
Pankaj Garg24-Feb-07 19:05
Pankaj Garg24-Feb-07 19:05 
AnswerRe: option explicit and option strict Pin
JUNEYT25-Feb-07 0:53
JUNEYT25-Feb-07 0:53 
GeneralRe: option explicit and option strict Pin
amaneet25-Feb-07 1:55
amaneet25-Feb-07 1:55 
GeneralRe: option explicit and option strict Pin
JUNEYT25-Feb-07 2:38
JUNEYT25-Feb-07 2:38 
Questiondouble link list Pin
Pankaj Garg24-Feb-07 19:02
Pankaj Garg24-Feb-07 19:02 
QuestionCustom DataGrid in VB.NET Pin
mariefitz24-Feb-07 14:23
mariefitz24-Feb-07 14:23 
QuestionVirus Checking Pin
Muhammad Nauman Yousuf24-Feb-07 14:12
Muhammad Nauman Yousuf24-Feb-07 14:12 
AnswerRe: Virus Checking Pin
Christian Graus24-Feb-07 16:21
protectorChristian Graus24-Feb-07 16:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.