Hello all
I have a fairly simple listbox into which I add, insert, and remove strings
It has the following property settings
HorizontalScrol lbar - true
HorizontalExten t -
ScrollAlwaysVis ible - Fals
The problem I am having is that the horizontal scrollbar range doesn't work right. If I add a string, the first time the sting width exceeds the control width the bar appears, but it's off by a few pixels so the last character is truncated. If I add longer items, it doesn't update so I can't see the end of them. If I insert items, it never updates. Delete only seems to work if the entire horizontal scrollbar should disappear
I ended up writing code (at end of this post) which goes through all the strings and uses the Graphics.Measur eString method, then sets HorizontalExten t to the maximum result. It works, but seems very cumbersome - and I can't find an event which fires when the Items-collection changes which could simply call this method. Instead, I need to go through my code and add calls to this at any point the collection might change
Is this a known issue with listboxes or am I doing something dumb. I can't believe proper scrollbar operation requires added code
Any tips appreciated
Marku
Here is the code I had to add
private void UpdateHorzScrol l()
Graphics g=Graphics.From Hwnd(Handle)
int wid=0
foreach (object obj in MyListBox.Items )
int swid=(int)(g.Me asureString(obj as string,Font).Wi dth)
if (swid > wid) wid=swid
MyListBox.Horiz ontalExtent=wid 0 1709 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lundy |
last post by:
greetings,
The listbox control on my aspx page has a vertical
scrollbar. But some of the text extends beyond the right
limit of the listbox. I don't see a horizontal scrollbar,
and I don't see any scrollbar properties in the property
sheet in vs2003. Would this be a styles item? If so, how
to invoke. If not, is it possible to invoke a horizontal
scrollbar? how to do that?
|
by: markusszil |
last post by:
Hello all
I have a fairly simple listbox into which I add, insert, and remove strings
It has the following property settings
HorizontalScrollbar - true
HorizontalExtent -
ScrollAlwaysVisible - Fals
The problem I am having is that the horizontal scrollbar range doesn't work right. If I add a string, the first time the sting width exceeds the control width the bar appears, but it's off by a few pixels so the last character is...
|
by: Mr. Beck |
last post by:
I have a simple application that has a listbox for displaying text in it.
The functionality of it is to color particular parts of the text that is
displayed from a file. I have used similar coding from
http://www.dotnet247.com/247reference/msgs/12/60727.aspx as a reference for
coloring the text.
The problem I am having is that when the text of the listbox is longer than
the size of the listbox, the horizontal scrollbar will not show up....
|
by: rn5a |
last post by:
How do I make a ListBox display the horizontal scrollbar if the text of
any of the items in the ListBox exceeds the width of the ListBox?
Unlike the vertical scrollbar which gets displayed automatically if the
number of items in the ListBox exceed the height of the ListBox, the
horizontal scrollbar doesn't get displayed automatically when the text
of any of the items in the ListBox exceeds the width of the ListBox!
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |