-
August 5th, 2008, 12:53 AM
#1
Split a long string data and display it in multiple lines of a ListView
I want to display a long string that is fetched from the database in a ListView.
As of now, the string is displayed in a single line of the ListView which makes it difficult to read the entire data.
I want it to be displayed in multiple lines within the ListView.
pls reply .... :-)
-
August 5th, 2008, 01:28 AM
#2
Re: Split a long string data and display it in multiple lines of a ListView
There's probably a better way, but this seems to work...
Code:
String longstring = "aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd";
String shortstring;
for (int i = 0; i < longstring.Length; i += 10)
{
if ((i + 10) <= longstring.Length)
shortstring = longstring.Substring(i, 10);
else
shortstring = longstring.Substring(i, (longstring.Length - i));
listView1.Items.Add(shortstring);
}
It's not a bug, it's a feature!
-
August 5th, 2008, 01:43 AM
#3
Re: Split a long string data and display it in multiple lines of a ListView
If it is a plain text without any metadata, then it makes no sence to display it in ListView. By what rule would you split it? Display it in TextBox with Multiline property set to true.
Last edited by boudino; August 5th, 2008 at 01:43 AM.
Reason: formatting
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
August 5th, 2008, 04:59 AM
#4
Re: Split a long string data and display it in multiple lines of a ListView
Dear foamy,
In fact the string in question, is being fetched from a database and it comes within a Datatable. Moreover, I'm using MS Access file for this project.
so I'm finding it difficult to split it in the way that u have suggested.
so, if u know any other means by which the splitting can be done do let me know about that..
thankyou :-)
-
August 5th, 2008, 05:11 AM
#5
Re: Split a long string data and display it in multiple lines of a ListView
That shouldn't really matter... As long as you retrieve the string from somewhere.
However, you should do as boudino suggested...
It's not a bug, it's a feature!
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
|