I am trying to get a form in a center screen programmatically. in the codes of Else part is executing perfectly.
Dim X%, Y%
Call FrmCommonCodes.FormLocationXYValues(X, Y)
If X = 100 And Y = 100 Then
'Me.StartPosition = FormStartPosition.CenterScreen
Me.StartPosition = Windows.Forms.FormStartPosition.CenterScreen
Else
Me.Location = New System.Drawing.Point(X, Y)
End If
''FrmCommonCodes.FormLocationXYValues()
Public Sub FormLocationXYValues(ByRef X As Double, ByRef Y As Double)
Using MyConnection As OleDb.OleDbConnection = GetConnection(), MyCommand As New OleDb.OleDbCommand("SELECT * FROM options", MyConnection)
If MyConnection.State = ConnectionState.Closed Then MyConnection.Open()
Using MyDataReader As OleDb.OleDbDataReader = MyCommand.ExecuteReader
While MyDataReader.Read
X = MyDataReader("formlocation_x")
Y = MyDataReader("formlocation_y")
Return
End While
End Using
End Using
End Sub
Aucun commentaire:
Enregistrer un commentaire