Click here to Skip to main content
16,006,065 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Public Variable Pin
shiroamachi17-Jan-06 17:10
shiroamachi17-Jan-06 17:10 
QuestionNeed help Flexgrid in VB.NET Pin
welbert17-Jan-06 15:38
welbert17-Jan-06 15:38 
AnswerRe: Need help Flexgrid in VB.NET Pin
Christian Graus17-Jan-06 16:20
protectorChristian Graus17-Jan-06 16:20 
GeneralRe: Need help Flexgrid in VB.NET Pin
welbert17-Jan-06 16:31
welbert17-Jan-06 16:31 
GeneralRe: Need help Flexgrid in VB.NET Pin
Christian Graus17-Jan-06 16:33
protectorChristian Graus17-Jan-06 16:33 
Questionscroll bars (vertical and horizontal) in listbox Pin
Joy Anne17-Jan-06 15:00
Joy Anne17-Jan-06 15:00 
AnswerRe: scroll bars (vertical and horizontal) in listbox Pin
Christian Graus17-Jan-06 15:36
protectorChristian Graus17-Jan-06 15:36 
AnswerRe: scroll bars (vertical and horizontal) in listbox Pin
Joshua Quick17-Jan-06 16:12
Joshua Quick17-Jan-06 16:12 
Unfortunately, the VB6 ListBox control doesn't give you direct access to the horizontal scrollbar. The only way to show it is via Win32 API. It isn't pretty.

I must be feeling extra generous today. Smile | :)
Here's my code that allows you to display a horizontal scrollbar just wide enough to show all of the ListBox's contents. All you have to do is pass a ListBox reference into the UpdateHorizontalScrollbar() function after adding your strings. It'll setup the scrollbar for you. The ListBox won't automatically adjust the horizontal scrollbar after adding/modifying strings, so you must call it again when changes occur.

' Define win32 functions.
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" _
  (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

' Analyzes given listbox and displays a horizontal scroll bar if needed.
Public Sub UpdateHorizontalScrollbar(lstCtrl As ListBox)
   Dim fMax As Single
   Dim fValue As Single
   Dim iIndex As Integer

   ' Get length of longest text in listbox.
   fMax = 0
   For iIndex = (lstCtrl.ListCount - 1) To 0 Step -1
      fValue = TextWidth(lstCtrl.List(iIndex))
      If (fValue > fMax) Then fMax = fValue
   Next

   ' Convert max text length to pixels.
   fMax = fMax / Screen.TwipsPerPixelX

   ' Increase length for checkboxes and margins (in pixels).
   If (1 = lstCtrl.Style) Then fMax = fMax + 13 ' Offset for checkbox.
   fMax = fMax + 4                              ' Offset for margins.

   ' Set horizontal scrollbar length.
   SendMessage lstCtrl.hWnd, &H194, CLng(fMax) + 1, 0&
End Sub

Questionbetween two forms Pin
militiaware17-Jan-06 14:28
militiaware17-Jan-06 14:28 
AnswerRe: between two forms Pin
Christian Graus17-Jan-06 14:33
protectorChristian Graus17-Jan-06 14:33 
QuestionInstaller selected directory. Pin
bskirkman17-Jan-06 13:04
bskirkman17-Jan-06 13:04 
AnswerRe: Installer selected directory. Pin
bskirkman17-Jan-06 14:46
bskirkman17-Jan-06 14:46 
QuestionVBA - Declare - Finding the Lib File - Windows Registry? Pin
JSadleir17-Jan-06 12:09
JSadleir17-Jan-06 12:09 
AnswerRe: VBA - Declare - Finding the Lib File - Windows Registry? Pin
Dave Kreskowiak17-Jan-06 13:58
mveDave Kreskowiak17-Jan-06 13:58 
GeneralRe: VBA - Declare - Finding the Lib File - Windows Registry? Pin
JSadleir17-Jan-06 17:00
JSadleir17-Jan-06 17:00 
GeneralRe: VBA - Declare - Finding the Lib File - Windows Registry? Pin
Dave Kreskowiak19-Jan-06 9:30
mveDave Kreskowiak19-Jan-06 9:30 
Questionhelp with arrays Pin
jszpila17-Jan-06 11:45
jszpila17-Jan-06 11:45 
AnswerRe: help with arrays Pin
Joshua Quick17-Jan-06 13:01
Joshua Quick17-Jan-06 13:01 
GeneralRe: help with arrays Pin
jszpila18-Jan-06 3:34
jszpila18-Jan-06 3:34 
QuestionAlignment problem displaying .txt file in window's textbox? Pin
Brightday17-Jan-06 5:40
Brightday17-Jan-06 5:40 
AnswerRe: Alignment problem displaying .txt file in window's textbox? Pin
Dave Kreskowiak17-Jan-06 6:37
mveDave Kreskowiak17-Jan-06 6:37 
GeneralRe: Alignment problem displaying .txt file in window's textbox? Pin
Brightday17-Jan-06 7:53
Brightday17-Jan-06 7:53 
GeneralDave - please send me an email !!! Pin
Christian Graus17-Jan-06 9:59
protectorChristian Graus17-Jan-06 9:59 
GeneralRe: Dave - please send me an email !!! Pin
Dave Kreskowiak17-Jan-06 10:33
mveDave Kreskowiak17-Jan-06 10:33 
Questionopen a form closing the opener Pin
ecentinela17-Jan-06 5:04
ecentinela17-Jan-06 5:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.