Board index » cppbuilder » Small Combobox Width and Large TStrings
LarryJ
![]() CBuilder Developer |
LarryJ
![]() CBuilder Developer |
Small Combobox Width and Large TStrings2007-04-10 05:22:53 AM cppbuilder102 I have a ComboBox set as "csDropDownList" that I must fit into a very small space. The width can only be 50. The TStrings property has text that is much larger than 50. When this box is dropped down the text area is cut off because the text area doesn't fit to the size of the text. I can't find any ComboBox property to make the text area adjust to fix to the size of the text. Is there a way to make the ComboBox adjust to the text size? Thanks Larry. |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2007-04-10 05:33:51 AM
Re:Small Combobox Width and Large TStrings
"LarryJ" < XXXX@XXXXX.COM >wrote in message
QuoteI can't find any ComboBox property to make the text area QuoteIs there a way to make the ComboBox adjust to the text size? list, you will have to compute the longest available string length and then send the message to the ComboBox. For example: int iNewWidth = 0; int iCount = ComboBox1->Items->Count; for(int i = 0; i < iCount; ++i) { int iWidth = ComboBox1->Canvas->TextWidth(ComboBox1->Items->Strings[i]); if( iWidth>iNewWidth ) iNewWidth = iWidth; } ComboBox1->Perform(CB_SETDROPPEDWIDTH, iNewLength, 0); Gambit |