如何使listbox的橫式捲軸出現?謝謝!
是要設定那個屬性?
2006-04-30 04:35:12 · 2 個解答 · 發問者 cat 1 in 電腦與網際網路 ➔ 程式設計
ListBox 好像沒有 Column 屬性 呢?
2006-05-01 06:20:55 · update #1
wjs
你的程式我看不太懂,有點複雜!
要使listbox的橫式捲軸出現,要這麼複雜嗎?
那是不是要將程式碼全部複制過去嗎?
2006-05-01 06:22:37 · update #2
Const LB_SETHORIZONTALEXTENT = &H194Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongDim List1 As ListBoxSub ListScroll() Dim m As Long, f As Font, I As Integer Me.ScaleMode = vbPixels ' 像素 Set f = Me.Font ' 保留表單的 Font Set Me.Font = List1.Font ' 將 List1 的 Font 設定給表單 With List1 For I = 0 To .ListCount If Me.TextWidth(.List(I)) > m Then m = Me.TextWidth(.List(I)) End If Next End With m = m + 10 ' 再加寬一點點 Set Me.Font = f ' 還原表單的 Font SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, m, ByVal 0&End SubPrivate Sub Form_Load()Dim I%, S$Height = 3450: Width = 2040Set List1 = Controls.Add("VB.ListBox", "List1") '動態載入List1List1.Height = ScaleHeight: List1.Width = ScaleWidth: List1.Visible = TrueFor I = 65 To 90 S = S & Chr(I) List1.AddItem SNextCall ListScrollEnd Sub
2006-05-01 13:10:34 補充:
我是利用API來使ListBox產生橫向捲軸,因若只改變Columns屬性雖有橫向捲軸但縱向捲軸卻會消失,故用API可達成兩者都有的方式.當然在Load時動態載入List是為了方便你直接複製程式就可執行,你可把它省略直接放個ListBox上去
2006-04-30 18:36:48 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
我想你應該將 ListBox 的 Column 屬性 設為 你想要的行數... 就可以有橫式捲軸了...例如你可以設為20 ,,,
2006-04-30 18:07:40 · answer #2 · answered by Isaac 2 · 0⤊ 0⤋