• 0

Need basic .NET dialog/form help


Question

I am using Microsoft Visual Studio Community 2015.

 

eb_dialog1.thumb.png.d5e2a2a8a181914f22b

 

When I click on the blue Change link, I want it to open Form2 (below) in the center and on top of Form1 (above)

 

eb_dialog2.thumb.png.0846d540e2c0cad90d2

 

Any ideas?

 

I am a beginner - go easy on me!
Link to comment
Share on other sites

16 answers to this question

Recommended Posts

  • 0
59 minutes ago, LimeMaster said:

Try this, assuming I understood what you meant:


            Form2 frm2 = new Form2();
            frm2.StartPosition = FormStartPosition.CenterParent;
            frm2.Show();

 

 

Where do I put that?

 

If I double-click on the blue Change link, it goes to:

Private Sub LinkLabel2_LinkClicked_2(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked

End Sub

If I paste your code between there, it throws a lot of failures, so I guess I'm pasting it in the wrong location?

Link to comment
Share on other sites

  • 0

Ignoring the above who seems to preach what he should have heeded less than 6 months back...

 

I'm feeling that you may be missing some basic knowledge here.  Care to paste either the errors or basic source?

Link to comment
Share on other sites

  • 0
5 minutes ago, Nik L said:

Ignoring the above who seems to preach what he should have heeded less than 6 months back...

 

I'm feeling that you may be missing some basic knowledge here.  Care to paste either the errors or basic source?

 

Error    BC32017    Comma, ')', or a valid expression continuation expected.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    159    Active

Error    BC30800    Method arguments must be enclosed in parentheses.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    159    Active

Error    BC30451    'frm2' is not declared. It may be inaccessible due to its protection level.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    159    Active
  
Error    BC30451    'frm2' is not declared. It may be inaccessible due to its protection level.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    160    Active

Error    BC30451    'frm2' is not declared. It may be inaccessible due to its protection level.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    161    Active

Error    BC30109    'Form2' is a class type and cannot be used as an expression.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    159    Active
  
Error    BC30037    Character is not valid.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    159    Active

Error    BC30037    Character is not valid.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    160    Active

Error    BC30037    Character is not valid.    WindowsApplication1    X:\LodarGUITest\WindowsApplication1\Form1.vb    161    Active

 
Link to comment
Share on other sites

  • 0

Those are syntactic errors, not "throwing failures" ("throwing an error" or more precisely an "exception" is a run-time behavior, i.e. something that the code does when running - here the error happens at compile-time.) Visual Studio should underline these with red squigglies like in Word. If you double-click the error in the "Error List" window, it'll point you directly to it: it also gives you the line number where the error is. If you still can't figure it out, paste the offending code here.

 

Note that you are using Visual Basic and that LimeMaster gave you C# code - you didn't specify which language you were using. You need to remove the semi-colons at the end of the lines and possibly there are other small discrepancies.

Link to comment
Share on other sites

  • 0
9 minutes ago, Elliot B. said:

Where do I put that?

 

If I double-click on the blue Change link, it goes to:


    Private Sub LinkLabel2_LinkClicked_2(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked


	    End Sub

If I paste your code between there, it throws a lot of failures, so I guess I'm pasting it in the wrong location?

Oh, so you're using VB not C#. Oops, my mistake:

 

Click the linkLabel and paste this:

 Form2.Show()

Then double click Form2 and paste this:

 Me.StartPosition = FormStartPosition.CenterParent

 

Link to comment
Share on other sites

  • 0
3 minutes ago, LimeMaster said:

Oh, so you're using VB not C#. Oops, my mistake:

 

Click the linkLabel and paste this:


 Form2.Show()

Then double click Form2 and paste this:


 Me.StartPosition = FormStartPosition.CenterParent

 

Much more like it - thank you a million! :)

Link to comment
Share on other sites

  • 0
17 minutes ago, Nik L said:

Damn, I take one phone call and miss all the fun.

If it helps, the box isn't opening in the center of Form1 :p

 

And for bonus stars, how do I "lock" Form1 until Form2 is closed?

Link to comment
Share on other sites

  • 0
1 minute ago, Elliot B. said:

If it helps, the box isn't opening in the center of Form1 :p

 

And for bonus stars, how do I "lock" Form1 until Form2 is closed?

Is Form1 at the center of the screen? Because if it is, then use the lazy CenterScreen method.  :p

Link to comment
Share on other sites

  • 0
On 10/12/2015, 08:53:40, Elliot B. said:

You guys are legends (Y)

Seeing as you're just getting started, do you mind a suggestion?

 

Drop VB.NET and learn C# instead. I know it might seem the easier option, and as far as .NET goes, just as capable as C#, but learning the syntax of C# will help you much more moving forward than VB will, due to its similarities with things such as Java, Javascript and C.

 

You'll also find far more learning materials available in C# than you will in VB...

 

Link to comment
Share on other sites

  • 0

And you get paid more :yes:

 

That said, if you know VB well it's very easy to switch to C#, almost all the features are equivalent with slightly different syntax. I actually started with VB too. Didn't last long, wanted to write XNA games and it only supported C#.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.