1.
獲顯示器的當期分辨:my.computer.screen.workingarea.size,返回width,height
可以單獨獲取width或height
my.computer.screen.workingarea.size.width
my.computer.screen.workingarea.size.height
2.設定窗體位置
螢幕**:form1.startposition=formstartposition.centerscreen
手動設定:form1
.startposition = formstartposition.manual
左100,上100畫素:form1.location = new point(100, 100)
單獨設定左邊距:form1.left = 300
單獨設定右邊距:form1.top = 300
3.邊距和窗體大小一起設定
dim myrect as new rectangle(200,100,300,300)
或單獨設定
dim myrect as
new rectangle
myrect.x = 200
myrect.y = 100
myrect.width = 300
myrect.height = 300
假設我的form1窗體的大小是400*400,我要設定往螢幕四個角落停靠,往邊上託,就可以自動停在角落
private sub mynotebook_move(byval sender as object, byval e as system.eventargs) handles me.move
'設定窗體往四個角落停靠方法
dim formx as int32 = my.computer.screen.workingarea.width - 400
dim formy as int32 = my.computer.screen.workingarea.height - 400
if me.location.x < 0 and me.location.y < 0 then
me.location = new point(0, 0)
elseif me.location.x < 0 and me.location.y > formy then
me.location = new point(0, formy)
elseif me.location.x > formx and me.location.y < 0 then
me.location = new point(formx, 0)
elseif me.location.x > formx and me.location.y > formy then
me.location = new point(formx, formy)
end if
end sub
Form窗體的監控
應用情形 winform中,有乙個登陸介面,乙個選單介面,然後就是處理業務介面,我們通過登陸介面跳轉到選單介面,然後通過選單選擇操作介面,那麼如何讓幾個窗體的出現和關閉流暢?下面 給出了解釋 form1為第乙個窗體,在form1中開啟form2,並監測form2的關閉事件,如果2關閉,則1恢復顯示或...
設定form的預設按鈕
很多情況下需要form窗體有個預設響應按鈕,就是在任何時候按下enter鍵都能響應那個按鈕的訊息,比如登入窗體,資料錄入窗體等等都有這樣的需要。設定方法 在form的acceptbutton屬性中設定所需的按鈕id即可 語句是this.acceptbutton yourdefaultbutton 如...
VB 讓外部程式在VB程式的窗體裡面執行
option explicit private declare function findwindow lib user32 alias findwindowa byval lpclassname as long,byval lpwindowname as long as long private ...