p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

vb_howto thread: Re: Combobox listing


Message #1 by C112NW <C112NW@s...> on Tue, 1 May 2001 13:36:35 +0900
Ravi,
Thanks so much for you help!!

Naomi

-----Original Message-----
From: RaviKumar Gurrapu [mailto:mail2grk@y...]
Sent: Tuesday, May 01, 2001 02:46 AM
To: VB_Howto
Subject: [vb_howto] Re: Combobox listing


Hi Naomi

The following solution will not work in all cases. I am giving temporary 
solution. Try to implement as per ur requirement.

Change validate event as follows.

Private Sub Combo1_Validate(Cancel As Boolean)
     'COMBO_TEXT = Trim(Left(Combo1.Text, 10))
     'Combo1.Text = COMBO_TEXT
     Combo1.Text = Trim(Left(Combo1, InStr(Combo1.Text, "|") - 1))
     Combo1.Width = 1500
 End Sub



Regards,
Ravi

> Dear all,
> I am using the combobox to show a listing consisting of 3 columns.  I 
want 
> the combobox size to be the size of the first column since I have 
another 
> combobox right next to the first one, but have the user able to view all 
3 
> columns for selection and when the user makes a selection only the item 
in 
> the first item to show in the combobox.
> I have tried using a few ways to do this but cannot achieve what I want 
to 
> do.  If anyone can help me I really really appreciate it.  I don't know 
> what else I can try.
> Below is the code for what I have tried.  This will overlap the combobox 
> next to the first one and doesn't work.
> You help will help me!!
> Thank you in advance.
> 
> Naomi 
> 
> Private Sub Combo1_GotFocus()
>     Combo1.Width = 8000
> End Sub
> 
> Private Sub Combo1_Validate(Cancel As Boolean)
>     COMBO_TEXT = Trim(Left(Combo1.Text, 10))
>     Combo1.Text = COMBO_TEXT
>     Combo1.Width = 1500
> End Sub
> 
> Private Sub Form_Load()
>     
>     Set rs2 = CreateObject("ADODB.Recordset")
>     rs2.Open "select * from shiplist", con, rdOpenForwardOnly, , 
adCmdText
>     Do Until rs2.EOF
>         Combo1.AddItem (Left(rs2("hull type") & Space(10), 10) & " | " & 
> Left(rs2("ship name") & Space(20), 20))
>         rs2.MoveNext
>     Loop


  Return to Index