473,698 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List Box question

Using a list box to display a text file, I am having to adjust the
length of the lines to fit the list box, (1) is there a way around
this? (2) Can one use rtf files with a list box, does that have coding
consequences when using the list box, if so which?
Many thanks.
--
Regards,
Patrick.
Nov 15 '05 #1
5 6874
Patrick,

Are you sure you are using a list box and not a textbox? The two have
very different functionality.

Why do you have to adjust the length of the lines to fit the textbox?
The textbox should wrap around the lines automatically.

If you use RTF files, then you will have to use a RichTextBox, which has
the same base as the TextBox class, but with more functionality.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldin o=at=exisconsul ting<dot>com

"Patrick De Ridder" <00*@000.00> wrote in message
news:h2******** *************** *********@4ax.c om...
Using a list box to display a text file, I am having to adjust the
length of the lines to fit the list box, (1) is there a way around
this? (2) Can one use rtf files with a list box, does that have coding
consequences when using the list box, if so which?
Many thanks.
--
Regards,
Patrick.

Nov 15 '05 #2
On Fri, 10 Oct 2003 10:17:10 -0400, "Nicholas Paldino [.NET/C# MVP]"
<ni************ **@exisconsulti ng.com> wrote:
Patrick,

Are you sure you are using a list box and not a textbox? The two have
very different functionality.

Why do you have to adjust the length of the lines to fit the textbox?
The textbox should wrap around the lines automatically.

If you use RTF files, then you will have to use a RichTextBox, which has
the same base as the TextBox class, but with more functionality.

Hope this helps.


I am using a list box because a text box takes only one line and I
have many lines to display. I am doing it like so:

for(int i = 0; i<k;i++)
{
show[i]=" "+strR2.ReadLin e();
}
listBox1.DataSo urce = show;

The lines that overrun the width are not wrapped. How should I do this
better? And in the case of a rich text box: how do I bind many lines
of rich text from a file to a rich text box?

Many thanks.
--
Regards,
Patrick.
Nov 15 '05 #3
Patrick,

This should not matter if your working with a WebForm or a WinForm.
What it sounds like you need to do is use a Textbox.

Set the Textbox property Multiline to true. And WordWrap to you needs.
Then resize the Textbox.

You can load a file by just setting the TextBox.Text property.
But if you were using the Listbox because you wanted to know what line
the user had selected then when loading the file split your string on
"\r\n" then assign the string array to the Lines property.

Also as another tip. To speed up the load, add all the file lines into
a System.Text.Str ingBuilder object first. Then assign the
StringBuilder.T oString() results to the TextBox.Text

Hope this helps.

Glen Jones MCSD
NewData
I am using a list box because a text box takes only one line and I
have many lines to display. I am doing it like so:

for(int i = 0; i<k;i++)
{
show[i]=" "+strR2.ReadLin e();
}
listBox1.DataSo urce = show;

The lines that overrun the width are not wrapped. How should I do this
better? And in the case of a rich text box: how do I bind many lines
of rich text from a file to a rich text box?

Many thanks.

Nov 15 '05 #4
On 11 Oct 2003 04:51:56 -0700, gl********@hotm ail.com (Glen Jones)
wrote:
Patrick,

This should not matter if your working with a WebForm or a WinForm.
What it sounds like you need to do is use a Textbox.

Set the Textbox property Multiline to true. And WordWrap to you needs.
Then resize the Textbox.

You can load a file by just setting the TextBox.Text property.
But if you were using the Listbox because you wanted to know what line
the user had selected then when loading the file split your string on
"\r\n" then assign the string array to the Lines property.

Also as another tip. To speed up the load, add all the file lines into
a System.Text.Str ingBuilder object first. Then assign the
StringBuilder. ToString() results to the TextBox.Text

Hope this helps.

Glen Jones MCSD
NewData


One you have displayed something in a textBox, how do you block the
user from making changes to the text?
--
Regards,
Patrick.
Nov 15 '05 #5
On Sat, 11 Oct 2003 19:14:33 +0200, Patrick De Ridder <00*@000.00>
wrote:

One you have displayed something in a textBox, how do you block the
user from making changes to the text?


I cracked that one.

Re textBoxes:

I am left with this question: Is it possible to have a margin on the
left hand side, or on both sides, so the text doesn't come right up to
the side(s), which doesn't look so good.

--
Regards,
Patrick.
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4289
by: Mike | last post by:
How do I extract a list of lists from a user defined function and print the results as strings for each list?
0
6372
by: Brian van den Broek | last post by:
Hi all, There have been a few posts over the last month or so expressing a bit of exasperation with the "rising tide of newbie's". (Or, more accurately, the rising tide of questions from newbie's not trying to follow ESR's advice.) A month or so ago (in a thread found here: http://tinyurl.com/5bj8j), I suggested that it might help the situation if there were a python.org wiki page that amounted to a "Welcome to the Python community;...
23
2263
by: Mike Meyer | last post by:
Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit confused, though - when would I use a list comp instead of a generator expression if I'm going to require 2.4 anyway? Thanks, <mike --
6
6292
by: Harry Overs | last post by:
My program needs to take a pointer to BYTE array (unsigned char*) and convert it into a STL list so that each BYTE in the array has its own element in the list, i.e. if the array has hundred bytes then the list needs to have a hundred entries, at present when I try to do this each element in my list points to the entire BYTE array, when what I really need is copies of each single BYTE in its own part of the list. I have used code similar...
19
13567
by: RAJASEKHAR KONDABALA | last post by:
Hi, Does anybody know what the fastest way is to "search for a value in a singly-linked list from its tail" as oposed to its head? I am talking about a non-circular singly-linked list, i.e., head and tail are not connected. Of course, recursive function aproach to traverse the list is one way. But, depending upon the list size, it could overrun the stack pretty fast.
15
25858
by: Andrew Brampton | last post by:
Hi, This may sound a odd question, but I wanted to know how you return a list of data from a function. These are some of the ways I know how, and I was wondering which method you normally use. This is more of a best practices question rather than a technical one. 1) Return a list instance ie std::list myFunction() { std::list list(); return list;
27
5133
by: comp.lang.tcl | last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML file into a TCL list as follows: attr1 {val1} attr2 {val2} ... attrN {valN} This is the TCL code that does this: set contents ]; close $fileID
1
2957
by: student2008 | last post by:
Sorry about the title its a tricky one. I have a form which allows me to add a question and answers into a mysql database via a combination of, if a certain option is chosen and the reset button is pressed then a text box appears to enter a new question or answer or both. the newly entered data is then inserted into mysql. The newly entered data is then requested by mysql_fetch_array() to be displayed as options in the drop down list. If...
17
3130
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note that I am using Allen Browne's multi-select list box for a report as a guide. I should also note that my access skills are not the best so I may need some explaining on certain things. First let me give some background on the database: I have a...
0
2277
by: saijin | last post by:
I'm planning to call a list of data from an XML file but when I duplicate the content inside the <data></data> it is not showing anything Here's the ActionScript 3.0 import fl.controls.ComboBox; import fl.controls.TextArea; import fl.containers.UILoader;
0
8609
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,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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,...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
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...
0
4371
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...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.