-
August 19th, 2012, 05:23 PM
#1
list box problem
Hi friends,
I want to put a long string in list box, which its width is more than width of list box.This is my problem:I want to put this long string in multiple lines
instead of using horizontal scroll.I mean when the string exceeds the end of line, it should back to the first of the next line.
Thanks
-
August 20th, 2012, 12:17 AM
#2
Re: list box problem
Standard list box does not support this multiline behavior.
You can:- Use owner drawn control and implement your custom multiline rendering, or
- Show a tooltip window while hovering over the long entry
Best regards,
Igor
-
August 20th, 2012, 01:09 AM
#3
Re: list box problem
And here is an example of Multi-Line ListBox
Victor Nijegorodov
-
August 20th, 2012, 01:41 AM
#4
Re: list box problem
Thank you for your helpful answers.
There is no difference for me to use list box or something else.
Is there an easier way to approach the mentioned purpose?
(show a long string in a small box)
-
August 20th, 2012, 02:50 AM
#5
Re: list box problem
I guess this multi-line list implementation would met your needs.
http://www.codeproject.com/Articles/...e-List-Control
-
August 20th, 2012, 07:13 AM
#6
Re: list box problem
Does it really need to be a list box? Do you need to select the different entries? An Edit or a Static control will display and wrap the text for you.
-
August 20th, 2012, 09:10 AM
#7
Re: list box problem
As I said before, there is no importance to use listbox or editbox or ...
I just need a small box to show a long string.for example this is my string :
str="Hello World! Hello World!";
my edit/list box isn't wide enough to show whole the string, so it just shows : Hello World! He
I want the result to be something like this:
Hello World!
Hello World!
-
August 20th, 2012, 09:22 AM
#8
Re: list box problem
Then use multiline style for the edit control (ES_MULTILINE) and if you'd like to allow user to set/change control text - additionally specify ES_WANTRETURN.
Victor Nijegorodov
-
August 20th, 2012, 09:27 AM
#9
Re: list box problem
Originally Posted by moottii
my edit/list box isn't wide enough to show whole the string, so it just shows : Hello World! He
I want the result to be something like this:
Hello World!
Hello World!
Then you could format the text using CRLF to achieve line breaks for both edit () and static controls:
Code:
m_myControl.SetWindowText(_T("Hello World!\r\nHello World!"));
where m_myControl is a control member variable of the control
Victor Nijegorodov
-
August 20th, 2012, 09:49 AM
#10
Re: list box problem
Thanks for you reply.
But unfortunately I don't know what my string is."Hello World!Hello World!" was an example.
In fact I'm writing a packet sniffer and I wanna show whole the data of each packet, into a separated box(this critical box)
So i'm not able to use that
m_myControl.SetWindowText(_T("1st part of string\r\n 2nd part of string"));
for going to the next line.
-
August 20th, 2012, 10:04 AM
#11
Re: list box problem
Originally Posted by moottii
Thanks for you reply.
But unfortunately I don't know what my string is."Hello World!Hello World!" was an example.
In fact I'm writing a packet sniffer and I wanna show whole the data of each packet, into a separated box(this critical box)
So i'm not able to use that
m_myControl.SetWindowText(_T("1st part of string\r\n 2nd part of string"));
for going to the next line.
As I said, an edit or static control will wrap for you.
-
August 20th, 2012, 04:09 PM
#12
Re: list box problem
http://msdn.microsoft.com/en-us/libr...rap_linebreaks
An application can use Wordwrap functions with multiline edit controls to locate the word or word fragment that should be wrapped to the next line. Using the default Wordwrap function provided by the system, lines always end at the spaces between words. An application can specify its own Wordwrap function by supplying an EditWordBreakProc Wordwrap function and sending the edit control an EM_SETWORDBREAKPROC message. An application can retrieve the address of the current Wordwrap function by sending the control an EM_GETWORDBREAKPROC message.
How do you use the default word wrapping for an edit control?
If you do not specify ES_AUTOHSCROLL, the control automatically wraps words to the beginning of the next line when necessary. A new line is also started if the user presses the ENTER key. The window size determines the position of the Wordwrap. If the window size changes, the Wordwrapping position changes and the text is redisplayed.
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|