string.split question
-
hi All, I am having trouble doing some string manipulation. I get a string with coma delimited. I want remove the first portion of the string. for example,strMessage = " I, Have, a, string, that, describe, something" what I want to do is that remove the first coma delimited part of the variable strMessage so it look like this "Have, a, string, that, describe, something" how do I do this. Any help appreciated. then I insert the string in my datagridview.
datagridview.Rows.Insert(0,strMessage.Split(','))
I want to keep this style of inserting into dataGridView just want to remove the first portion of the string which is "I". thanks
-
hi All, I am having trouble doing some string manipulation. I get a string with coma delimited. I want remove the first portion of the string. for example,strMessage = " I, Have, a, string, that, describe, something" what I want to do is that remove the first coma delimited part of the variable strMessage so it look like this "Have, a, string, that, describe, something" how do I do this. Any help appreciated. then I insert the string in my datagridview.
datagridview.Rows.Insert(0,strMessage.Split(','))
I want to keep this style of inserting into dataGridView just want to remove the first portion of the string which is "I". thanks
string.Split() is the method you want; it has a few overloads, so I refer to its documentation. BTW: you won't solve problems any faster by putting as much as possible into a single statement. Split things up, and look at the intermediate values while debugging. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
hi All, I am having trouble doing some string manipulation. I get a string with coma delimited. I want remove the first portion of the string. for example,strMessage = " I, Have, a, string, that, describe, something" what I want to do is that remove the first coma delimited part of the variable strMessage so it look like this "Have, a, string, that, describe, something" how do I do this. Any help appreciated. then I insert the string in my datagridview.
datagridview.Rows.Insert(0,strMessage.Split(','))
I want to keep this style of inserting into dataGridView just want to remove the first portion of the string which is "I". thanks
-
hi All, I am having trouble doing some string manipulation. I get a string with coma delimited. I want remove the first portion of the string. for example,strMessage = " I, Have, a, string, that, describe, something" what I want to do is that remove the first coma delimited part of the variable strMessage so it look like this "Have, a, string, that, describe, something" how do I do this. Any help appreciated. then I insert the string in my datagridview.
datagridview.Rows.Insert(0,strMessage.Split(','))
I want to keep this style of inserting into dataGridView just want to remove the first portion of the string which is "I". thanks
-
hi All, I am having trouble doing some string manipulation. I get a string with coma delimited. I want remove the first portion of the string. for example,strMessage = " I, Have, a, string, that, describe, something" what I want to do is that remove the first coma delimited part of the variable strMessage so it look like this "Have, a, string, that, describe, something" how do I do this. Any help appreciated. then I insert the string in my datagridview.
datagridview.Rows.Insert(0,strMessage.Split(','))
I want to keep this style of inserting into dataGridView just want to remove the first portion of the string which is "I". thanks
string[] parts = strMessage.Split(",");
for (int i = 0; i < parts.Length; i++)
{
parts[i] = parts[i].Trim();
}
dataGridView.Rows.Insert(0, parts);But don't you need to ensure that the number of parts matches the number of columns you have in the row?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997