Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
QuestionHow can I copy a multidimensional List Pin
leekangjae20-Jan-10 15:23
leekangjae20-Jan-10 15:23 
AnswerRe: How can I copy a multidimensional List Pin
Not Active20-Jan-10 15:39
mentorNot Active20-Jan-10 15:39 
GeneralRe: How can I copy a multidimensional List Pin
leekangjae20-Jan-10 17:41
leekangjae20-Jan-10 17:41 
AnswerRe: How can I copy a multidimensional List Pin
AspDotNetDev20-Jan-10 16:25
protectorAspDotNetDev20-Jan-10 16:25 
GeneralRe: How can I copy a multidimensional List Pin
Luc Pattyn20-Jan-10 16:51
sitebuilderLuc Pattyn20-Jan-10 16:51 
GeneralRe: How can I copy a multidimensional List Pin
AspDotNetDev20-Jan-10 17:08
protectorAspDotNetDev20-Jan-10 17:08 
GeneralRe: How can I copy a multidimensional List Pin
AspDotNetDev20-Jan-10 17:10
protectorAspDotNetDev20-Jan-10 17:10 
GeneralRe: How can I copy a multidimensional List Pin
AspDotNetDev20-Jan-10 17:15
protectorAspDotNetDev20-Jan-10 17:15 
GeneralRe: How can I copy a multidimensional List Pin
Luc Pattyn20-Jan-10 17:47
sitebuilderLuc Pattyn20-Jan-10 17:47 
QuestionSimulate keypress Pin
Matt Cavanagh20-Jan-10 14:12
Matt Cavanagh20-Jan-10 14:12 
AnswerRe: Simulate keypress Pin
Bekjong20-Jan-10 16:07
Bekjong20-Jan-10 16:07 
QuestionProblem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
FJJCENTU20-Jan-10 13:27
FJJCENTU20-Jan-10 13:27 
AnswerRe: Problem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
Bekjong20-Jan-10 15:50
Bekjong20-Jan-10 15:50 
AnswerRe: Problem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
Giorgi Dalakishvili20-Jan-10 19:17
mentorGiorgi Dalakishvili20-Jan-10 19:17 
QuestionManaged and Unmanaged code Pin
3bood.ghzawi20-Jan-10 13:03
3bood.ghzawi20-Jan-10 13:03 
AnswerRe: Managed and Unmanaged code Pin
Bekjong20-Jan-10 15:53
Bekjong20-Jan-10 15:53 
AnswerRe: Managed and Unmanaged code Pin
Abhinav S20-Jan-10 17:33
Abhinav S20-Jan-10 17:33 
QuestionDisplay highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:02
CarlMartin1020-Jan-10 13:02 
AnswerRe: Display highlighted data from Listbox in Textboxes Pin
Luc Pattyn20-Jan-10 13:27
sitebuilderLuc Pattyn20-Jan-10 13:27 
Hi,

I have a lot of comments, here are some:

1.
you should not try and keep a lot of information in a single string, so string[] Contacts isn't a good choice.

2.
you should also not try and keep an unknown number of items in an array, as that will become a functional limitation, and needs code to guard you against an overflow. Instead use some kind of list; ArrayList is simple, however it got superceded by List<sometype> which is known as a generic list.

3.
a ListBox can hold items of any kind you choose, not just strings. So what you could and should do is:
- declare a Contact class, with all the fields you like;
- create, then add, such Contact instances to the ListBox;
- to get it painted, do one of these:
   a) give Contact a ToString() method that lists all fields, each with a constant width (i.e. use string.PadRight() or string.PadLeft() to add spaces;
   b) make the ListBox ownerdrawn, and provide a DrawItem handler which basically does a Graphics.DrawString() for each of the fields.

4.
If you want to be able to sort your contacts on each of the fields, then you would be better of with a DataGridView

5.
some comments on coding style:
- don't call ToString() on strings, as it doesn't achieve anything (see Contacts[j].ToString())
- don't use short identifiers for class members (your int i); a one-letter identifier is OK for a local for loop, not for a state variable.
- don't create empty catch blocks; always specify what it is you catch, and then show it, so no problem can go unnoticed and waste hours of debugging. Example:
try {
    ...
} catch(Exception exc) {
    MessageBox.Show(exc.ToString());
}


6.
and finally, if you haven't done so yet, buy and study a book on C#, it introduces you to all major language features and good coding practices.

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]


GeneralRe: Display highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:31
CarlMartin1020-Jan-10 13:31 
GeneralRe: Display highlighted data from Listbox in Textboxes Pin
Luc Pattyn20-Jan-10 13:37
sitebuilderLuc Pattyn20-Jan-10 13:37 
AnswerRe: Display highlighted data from Listbox in Textboxes Pin
Anthony Mushrow20-Jan-10 13:34
professionalAnthony Mushrow20-Jan-10 13:34 
GeneralRe: Display highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:37
CarlMartin1020-Jan-10 13:37 
Questionuse of information from a previous form Pin
naghoumeh1420-Jan-10 10:22
naghoumeh1420-Jan-10 10:22 
AnswerRe: use of information from a previous form Pin
sanforjackass20-Jan-10 10:42
sanforjackass20-Jan-10 10:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.