PC Review


Reply
Thread Tools Rate Thread

Combobox Events to Shrink and Expand Width

 
 
RyanH
Guest
Posts: n/a
 
      13th Oct 2008
This is something that is a thorn in my side that I can't figure out. It's
probably not worth the time I have put into it, but that is programming I
guess.

I have a combobox that contains a list of 2 columns. Column 1 is displayed
in the textbox portion of the combobox and it contains two letter intials
that represent what is in Column 2, which is the description. For example,

' Product Code Description
Column 1 Column 2
PF Plastic Face
CC Custom Cabinet
PT Parts

Column 1 is the Product Code and shows in the textbox portion. Column 2
shows in the drop down list. The combobox needs to have an original width =
53, but I need to expand it to 120 if the user wants to change the product
code so they can see the full description.

This is what I have but the combobox doesn't go back to the origianl size of
53 after the combobox has been changed. Anyone have any ideas? This what I
have:

Private Sub cboProductCode_Change()
' put combobox to it original width
cboProductCode.Width = 53
End Sub

Private Sub cboProductCode_DropButtonClick()
' expand combobox to view list
cboProductCode.Width = 120
End Sub
--
Cheers,
Ryan
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      13th Oct 2008
I think you have stumbled across an anomaly. I tried this code.

Private Sub cboProductCode_Change()
' put combobox to it original width
cboProductCode.ColumnCount = 1
's = Timer + 2
'Do While Timer < s
' DoEvents
'Loop
If cboProductCode.ColumnCount = 1 Then
cboProductCode.Width = 53
End If
End Sub

Private Sub cboProductCode_DropButtonClick()
' expand combobox to view list
cboProductCode.ColumnCount = 2
cboProductCode.Width = 120
End Sub

When running the code with the comment marks removed, it changes the size of
the combobox OK, but as soon as the dropdown arrow is clicked, it adds the
second column back in and expands the size. Yet, I can manually walk through
the code to reduce the size back to one column and 53 pts and it allows me to
drop down with only one column visible. I threw in the delay to see if that
would give the same effect as doing it manually, but no luck. Weird! Sorry
Ryan, guess I can't help.



"RyanH" wrote:

> This is something that is a thorn in my side that I can't figure out. It's
> probably not worth the time I have put into it, but that is programming I
> guess.
>
> I have a combobox that contains a list of 2 columns. Column 1 is displayed
> in the textbox portion of the combobox and it contains two letter intials
> that represent what is in Column 2, which is the description. For example,
>
> ' Product Code Description
> Column 1 Column 2
> PF Plastic Face
> CC Custom Cabinet
> PT Parts
>
> Column 1 is the Product Code and shows in the textbox portion. Column 2
> shows in the drop down list. The combobox needs to have an original width =
> 53, but I need to expand it to 120 if the user wants to change the product
> code so they can see the full description.
>
> This is what I have but the combobox doesn't go back to the origianl size of
> 53 after the combobox has been changed. Anyone have any ideas? This what I
> have:
>
> Private Sub cboProductCode_Change()
> ' put combobox to it original width
> cboProductCode.Width = 53
> End Sub
>
> Private Sub cboProductCode_DropButtonClick()
> ' expand combobox to view list
> cboProductCode.Width = 120
> End Sub
> --
> Cheers,
> Ryan

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      13th Oct 2008
The combobox doesn't like to resize while it is in the state of dropdown.
You could call an OnTime macro to change it but why not do it in the Exit
event. That would also resize it even if user does not change a value in
which scenario the change event would not even fire.

Regards,
Peter T


"RyanH" <(E-Mail Removed)> wrote in message
news:5BCBB566-1084-4E9E-A0CD-(E-Mail Removed)...
> This is something that is a thorn in my side that I can't figure out.
> It's
> probably not worth the time I have put into it, but that is programming I
> guess.
>
> I have a combobox that contains a list of 2 columns. Column 1 is
> displayed
> in the textbox portion of the combobox and it contains two letter intials
> that represent what is in Column 2, which is the description. For
> example,
>
> ' Product Code Description
> Column 1 Column 2
> PF Plastic Face
> CC Custom Cabinet
> PT Parts
>
> Column 1 is the Product Code and shows in the textbox portion. Column 2
> shows in the drop down list. The combobox needs to have an original width
> =
> 53, but I need to expand it to 120 if the user wants to change the product
> code so they can see the full description.
>
> This is what I have but the combobox doesn't go back to the origianl size
> of
> 53 after the combobox has been changed. Anyone have any ideas? This what
> I
> have:
>
> Private Sub cboProductCode_Change()
> ' put combobox to it original width
> cboProductCode.Width = 53
> End Sub
>
> Private Sub cboProductCode_DropButtonClick()
> ' expand combobox to view list
> cboProductCode.Width = 120
> End Sub
> --
> Cheers,
> Ryan



 
Reply With Quote
 
RyanH
Guest
Posts: n/a
 
      14th Oct 2008
I read the help on DoEvents and don't really understand it. What are some
situations you would need to use DoEvents and what does it do exactly?
--
Cheers,
Ryan


"JLGWhiz" wrote:

> I think you have stumbled across an anomaly. I tried this code.
>
> Private Sub cboProductCode_Change()
> ' put combobox to it original width
> cboProductCode.ColumnCount = 1
> 's = Timer + 2
> 'Do While Timer < s
> ' DoEvents
> 'Loop
> If cboProductCode.ColumnCount = 1 Then
> cboProductCode.Width = 53
> End If
> End Sub
>
> Private Sub cboProductCode_DropButtonClick()
> ' expand combobox to view list
> cboProductCode.ColumnCount = 2
> cboProductCode.Width = 120
> End Sub
>
> When running the code with the comment marks removed, it changes the size of
> the combobox OK, but as soon as the dropdown arrow is clicked, it adds the
> second column back in and expands the size. Yet, I can manually walk through
> the code to reduce the size back to one column and 53 pts and it allows me to
> drop down with only one column visible. I threw in the delay to see if that
> would give the same effect as doing it manually, but no luck. Weird! Sorry
> Ryan, guess I can't help.
>
>
>
> "RyanH" wrote:
>
> > This is something that is a thorn in my side that I can't figure out. It's
> > probably not worth the time I have put into it, but that is programming I
> > guess.
> >
> > I have a combobox that contains a list of 2 columns. Column 1 is displayed
> > in the textbox portion of the combobox and it contains two letter intials
> > that represent what is in Column 2, which is the description. For example,
> >
> > ' Product Code Description
> > Column 1 Column 2
> > PF Plastic Face
> > CC Custom Cabinet
> > PT Parts
> >
> > Column 1 is the Product Code and shows in the textbox portion. Column 2
> > shows in the drop down list. The combobox needs to have an original width =
> > 53, but I need to expand it to 120 if the user wants to change the product
> > code so they can see the full description.
> >
> > This is what I have but the combobox doesn't go back to the origianl size of
> > 53 after the combobox has been changed. Anyone have any ideas? This what I
> > have:
> >
> > Private Sub cboProductCode_Change()
> > ' put combobox to it original width
> > cboProductCode.Width = 53
> > End Sub
> >
> > Private Sub cboProductCode_DropButtonClick()
> > ' expand combobox to view list
> > cboProductCode.Width = 120
> > End Sub
> > --
> > Cheers,
> > Ryan

 
Reply With Quote
 
RyanH
Guest
Posts: n/a
 
      14th Oct 2008
I have used the Exit Event before, but the control has to loose focus before
it fires. I guess I will have to live with the combo box expanded until the
use click somewhere else.
--
Cheers,
Ryan


"Peter T" wrote:

> The combobox doesn't like to resize while it is in the state of dropdown.
> You could call an OnTime macro to change it but why not do it in the Exit
> event. That would also resize it even if user does not change a value in
> which scenario the change event would not even fire.
>
> Regards,
> Peter T
>
>
> "RyanH" <(E-Mail Removed)> wrote in message
> news:5BCBB566-1084-4E9E-A0CD-(E-Mail Removed)...
> > This is something that is a thorn in my side that I can't figure out.
> > It's
> > probably not worth the time I have put into it, but that is programming I
> > guess.
> >
> > I have a combobox that contains a list of 2 columns. Column 1 is
> > displayed
> > in the textbox portion of the combobox and it contains two letter intials
> > that represent what is in Column 2, which is the description. For
> > example,
> >
> > ' Product Code Description
> > Column 1 Column 2
> > PF Plastic Face
> > CC Custom Cabinet
> > PT Parts
> >
> > Column 1 is the Product Code and shows in the textbox portion. Column 2
> > shows in the drop down list. The combobox needs to have an original width
> > =
> > 53, but I need to expand it to 120 if the user wants to change the product
> > code so they can see the full description.
> >
> > This is what I have but the combobox doesn't go back to the origianl size
> > of
> > 53 after the combobox has been changed. Anyone have any ideas? This what
> > I
> > have:
> >
> > Private Sub cboProductCode_Change()
> > ' put combobox to it original width
> > cboProductCode.Width = 53
> > End Sub
> >
> > Private Sub cboProductCode_DropButtonClick()
> > ' expand combobox to view list
> > cboProductCode.Width = 120
> > End Sub
> > --
> > Cheers,
> > Ryan

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I expand & shrink columns? youngsequan Microsoft Excel Misc 1 4th Dec 2009 11:44 PM
Fixed width table with a 100% width image in it is assuming theimages intrinsic size, although it does shrink the image satya.komatineni@gmail.com Windows XP Internet Explorer 4 31st Dec 2007 06:55 PM
dropdownlist expand display width not control width Ganesh Microsoft ASP .NET 0 16th Nov 2007 05:22 PM
shrink to fit expand =?Utf-8?B?Q3VydA==?= Microsoft Excel Programming 0 19th Oct 2007 05:59 PM
Expand & Shrink a Form George Nicholson Microsoft Access Form Coding 0 8th Aug 2007 09:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 AM.