日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Anchor属性

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

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

AnchorStyles 值的按位組合。默認值是 TopLeft

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

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

下面的代碼示例將 Button 添加到窗體并設置該控件的一些通用屬性。示例將該按鈕定位在窗體的右下角,因此調整窗體大小時其相對位置不變。接著,它設置 BackgroundImage 并將該按鈕的大小調整為與 同樣的大小。然后,該示例將 TabStop 設置為 true,并設置 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); }

轉載于:https://www.cnblogs.com/irving314/archive/2011/06/23/anchorstyle.html

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。