I got 3 form that is form1,form2,form3
I create a mainmenu to call form2 or form3
I got problem to getcenter the form2 or form3 in FORM 1....
Anyone have idea?...
This is what I came up with thinking quickly. The code is for the client forms
Public Class Form2 Private Sub Form2_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated ' Call resize to position this form _after_ creation ' Call with dummy (empty) args Form2_Resize(Me, New System.EventArgs) End Sub Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' End Sub Private Sub Form2_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize ' Center to calling form Dim ParentX As Integer ' Y coordinate Dim ParentY As Integer ' X coordinate Dim ParentHeight As Integer ' Height Dim ParentWidth As Integer ' Width Dim NewY As Integer ' This form's new vertical position Dim NewX As Integer ' This form's new horizontal position ' NOTICE: You have to know the name of the calling form ' Form1.Location.X and Form1.Location.Y return the parent's screen coordinates ParentY = Form1.Location.Y ParentX = Form1.Location.X ' Get Form1 size ParentHeight = Form1.Height ParentWidth = Form1.Width ' Calculate vertical position NewY = ParentY + (ParentHeight \ 2) - (Me.Height \ 2) ' Calculate horizontal position NewX = ParentX + (ParentWidth \ 2) - (Me.Width \ 2) ' Set the position Me.Location = New Point(NewX, NewY) End Sub End Class
I commented the code as well as I could so it should be self-explanatory. Form2_Resize sub may not be the best place to relocate form, but you can put the calculation to some other sub.
hi i am using vb.net multidimensional arrays and i am getting the nearest or closest number i just want to ask if my code was correct or not ? for example i have an input of 13000 and nearest number should be on col 6 can you please help me ...
I am developing a simple job card creator application with VB.net 2012, using Access 2010 as database.
The code I have generated to write data from a datagridview to the database table is successfully saving the data, but with an error "Parameter @name has no default value". The ...
write a C++ program which take inputs from the user/keyboard and calculate his ZAKAT.
get the input from user may include
-Amount invested in business
-Amount given to other business partners as loan
-Amount payable to others