掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
コンボボックスのドロップダウンの幅について (ID:90099)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
とりあえずこんなかんじかと、本来ここで幅を取得するべきでないかも しれませんが、「コンボボックスのことはコンボボックスに任せる。」 私は後のメンテナンスのためこんな発想でやっています。 Private Sub ComboBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.MouseEnter Dim i As Integer Dim margin As Integer = 10 Dim max_Width As New SizeF Dim MyGraphics As System.Drawing.Graphics MyGraphics = Me.CreateGraphics For i = 0 To ComboBox1.Items.Count - 1 max_Width = MyGraphics.MeasureString(ComboBox1.Items.Item(i), ComboBox1.Font) Next ComboBox1.DropDownWidth = margin + max_Width.Width MyGraphics.Dispose() End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.