开发者

Why can I not set right property in vb

I want my form to appear at the right edge of my screen but I not use since Right is readonly .Is there a solution for 开发者_运维问答this?

Right= My.Computer.Screen.WorkingArea.Right 


Use this code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim x As Integer = My.Computer.Screen.WorkingArea.Right - Me.Width
    Dim y As Integer = My.Computer.Screen.WorkingArea.Bottom / 2 - Me.Height / 2
    Me.Location = New Point(x, y)
End Sub

The Y-Coordinate is not much specified in your question, so I took it as the center..! Basically you need to subtract the width of the form from the right edge, only then it will appear as you wanted.

Cheers..


I used following and it worked

Left= My.Computer.Screen.WorkingArea.Right -Width


We won't know why until you give us more information such as an error message.

Dim nRight As Integer = My.Computer.Screen.WorkingArea.Right

works just fine.


Set the Location property instead.


If you want to move the form to the right edge of the screen by stretching the form, you can use something like this:

Me.Width = Me.Width + My.Computer.Screen.WorkingArea.Right - (Me.Left + Me.Width)

If you want to move the form to the right edge of the screen without changing its width, you can use this:

Me.Left = Me.Left + My.Computer.Screen.WorkingArea.Right - (Me.Left + Me.Width)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜