日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Anchor属性

發(fā)布時間:2024/9/5 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Anchor属性 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Control.Anchor 屬性 :獲取或設(shè)置控件綁定到的容器的邊緣并確定控件如何隨其父級一起調(diào)整大小。

AnchorStyles 值的按位組合。默認(rèn)值是 TopLeft

使用 Anchor 屬性可以定義在調(diào)整控件的父控件大小時如何自動調(diào)整控件的大小。將控件錨定到其父控件后,可確保當(dāng)調(diào)整父控件的大小時錨定的邊緣與父控件的邊緣的相對位置保持不變。

一個控件可以錨定到其容器的一個或多個邊緣。例如,如果有一個帶有 Button 的 Form,而該按鈕的 Anchor 屬性值設(shè)置為 TopBottom,當(dāng) Form 的 Height 增加時,Button 伸展,以保持到 Form 的上邊緣和下邊緣的錨定距離不變。

下面的代碼示例將 Button 添加到窗體并設(shè)置該控件的一些通用屬性。示例將該按鈕定位在窗體的右下角,因此調(diào)整窗體大小時其相對位置不變。接著,它設(shè)置 BackgroundImage 并將該按鈕的大小調(diào)整為與 同樣的大小。然后,該示例將 TabStop 設(shè)置為 true,并設(shè)置 TabIndex 屬性。最后,它添加一個事件處理程序以處理按鈕的 Click 事件。此示例要求您有一個名為 imageList1 的 ImageList。

// Add a button to a form and set some of its common properties. private void AddMyButton() {// Create a button and add it to the form.Button button1 = new Button();// Anchor the button to the bottom right corner of the formbutton1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);// Assign a background image.button1.BackgroundImage = imageList1.Images[0];// Specify the layout style of the background image. Tile is the default.button1.BackgroundImageLayout = ImageLayout.Center;// Make the button the same size as the image.button1.Size = button1.BackgroundImage.Size;// Set the button's TabIndex and TabStop properties.button1.TabIndex = 1;button1.TabStop = true;// Add a delegate to handle the Click event.button1.Click += new System.EventHandler(this.button1_Click);// Add the button to the form.this.Controls.Add(button1); }

轉(zhuǎn)載于:https://www.cnblogs.com/irving314/archive/2011/06/23/anchorstyle.html

總結(jié)

以上是生活随笔為你收集整理的Anchor属性的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。