主婦と.NETと犬のぶろぐ

奥様 と プログラム と お犬様 の 楽しい日常

目次

Blog 利用状況

ニュース

書庫

日記カテゴリ

GroupBox(System.Windows.Forms.GroupBox)

VB6.0 の時からお世話になってるコントロールです。
.NET Framework2.0 だと、AutoSize なるプロパティがあります。
今回はそいつで遊んでみました。


あと、関係ないんですけども、HTML で GroupBox っぽいのを実現するタグの名前をいつも忘れるので
メモ。fieldset(とほほのWWW入門)

ふじことえでんとかの人気投票 ふじこ
えでん
オット

■参考文献
GroupBox コントロール (Windows フォーム)
GroupBox クラス
AutoSizeMode 列挙体

■実行画像
AutoSize=False
GroupBox AutoSize=False
AutoSize=True
GroupBox AutoSize=True

Public Class GroupBoxTest

Private Sub GroupBoxTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList ' AutoSizeMode With Me.ComboBox1.Items .Add(System.Windows.Forms.AutoSizeMode.GrowAndShrink) .Add(System.Windows.Forms.AutoSizeMode.GrowOnly) End With
' 現在の GroupBox の値を ComboBox に設定 Me.CheckBox1.Checked = Me.GroupBox1.AutoSize Me.ComboBox1.Enabled = Me.CheckBox1.Checked Me.ComboBox1.SelectedItem = Me.GroupBox1.AutoSizeMode ' ComboBox が変更されたら、その値を GroupBox のプロパティに反映する AddHandler ComboBox1.SelectedIndexChanged, AddressOf Me.SetComboBoxValueToGroupBox
' Control を詰め込む。 For index As Integer = 1 To 10 Dim chk As CheckBox = New CheckBox() chk.Text = index.ToString() chk.Location = New Point(10, 20 * (index - 1) + 15) Me.GroupBox1.Controls.Add(chk) Next Me.GroupBox1.Text = "ふじことえでん~♪" End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged Me.ComboBox1.Enabled = Me.CheckBox1.Checked Me.SetComboBoxValueToGroupBox(sender, EventArgs.Empty) End Sub
' ComboBox とかの値を GroupBox の該当プロパティにセットする Private Sub SetComboBoxValueToGroupBox(ByVal sender As Object, ByVal e As System.EventArgs) Me.GroupBox1.AutoSize = Me.CheckBox1.Checked If Me.GroupBox1.AutoSize AndAlso Not Me.ComboBox1.SelectedItem Is Nothing Then Me.GroupBox1.AutoSizeMode = DirectCast(Me.ComboBox1.SelectedItem, AutoSizeMode) End If End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '' GroupBox 内の CheckBox の状態を一覧出力 'For Each ctrl As Control In Me.GroupBox1.Controls ' If TypeOf (ctrl) Is CheckBox Then ' Dim chk As CheckBox = DirectCast(ctrl, CheckBox) ' System.Diagnostics.Debug.WriteLine(chk.Text & ":" & chk.Checked.ToString()) ' End If 'Next
' 現在の GroupBox の大きさを表す四角形を描画 Dim rect As Rectangle = Me.GroupBox1.DisplayRectangle System.Diagnostics.Debug.WriteLine("Rectangle_H:" & rect.Size.Height.ToString()) System.Diagnostics.Debug.WriteLine("Rectangle_W:" & rect.Size.Width.ToString()) System.Diagnostics.Debug.WriteLine("GroupBox_H:" & Me.GroupBox1.Size.Height.ToString()) System.Diagnostics.Debug.WriteLine("GroupBox_W:" & Me.GroupBox1.Size.Width.ToString()) End Sub End Class

投稿日時 : 2007年1月23日 12:44

Feedback

# HVIHVWRXsTTZuRlhGP 2014/08/27 23:21 http://crorkz.com/

oYHzCf You must participate in a contest for probably the greatest blogs on the web. I'll suggest this website!

# VizgdJpXpAwNOZGXPfS 2014/08/29 12:02 http://nubiadesign.com/blog/

Very good written story. It will be useful to everyone who employess it, including me. Keep doing what you are doing - i will definitely read more posts.

# MZDoGzkmceYIBIoiiF 2014/09/08 18:07 http://www.arrasproperties.com/

Hi my loved one! I wish to say that this post is amazing, great written and include almost all vital infos. I'd like to look extra posts like this .

# MJjUVhdEPM 2014/09/09 7:29 http://vendere-su-internet.com/luis-souto/

Would you be interested by exchanging hyperlinks?

# zyIbqlPITYoLRWhOug 2014/09/14 17:44 http://www.escortsinlondon.tv/

Excellent web site. A lot of useful info here. I'm sending it to a few buddies ans additionally sharing in delicious. And obviously, thanks on your sweat!

# Tһere are thousands of Filipino girls іn South Korea. 2018/06/30 16:43 Tere аre thousands of Filipino girls іn South Kore

Therе are thousands of Filipino girls ?n South Korea.

# Greetings I am so thrilled I found your web site, I really found you by error, while I was searching on Aol for something else, Nonetheless I am here now and would just like to say cheers for a tremendous post and a all round thrilling blog (I also love 2022/01/18 15:56 Greetings I am so thrilled I found your web site,

Greetings I am so thrilled I found your web site, I really found you by error,
while I was searching on Aol for something else, Nonetheless I
am here now and would just like to say cheers for a tremendous post and a all round thrilling blog (I also love the theme/design), I don’t have time to read it all at the minute but I have book-marked it and also added
in your RSS feeds, so when I have time I will be back to read a great deal
more, Please do keep up the great jo.

http://fr79058b.bget.ru/548.html
https://yclass.proyecciontotal.com/internship/twosday-2022-t-shirt-five-classes-about-shirt-it-s-essential-be-taught-to-succeed.html
https://theyclassifieds.com/market/twosday-2022-shirt-t-shirt-printing-tucson-secrets-arizona-clothes.html
https://godagang.com/openclass/spanish/twosday-t-shirt-6-more-cool-tools-for-shirt-size-chart.html
https://usedelectricars.com/jobs/twosday-t-shirt-learn-how-to-measure-yourself-for-a-hand-made-shirt-clothes.html
https://sync-sound.com/yclas/au-pair/twosday-2022-shirt-mens-dress-shirts-how-to-choose-a-tie-that-befits-your-model.html

タイトル  
名前  
Url
コメント