I have 5 values in datagridview column with comma like
abc,xyz,asdf,qwer,mni
how to split into string and display in textbox
abc
xyz
asdf
qwer
mni
I have 5 values in datagridview column with comma like
abc,xyz,asdf,qwer,mni
how to split into string and display in textbox
abc
xyz
asdf
qwer
mni
OP Says, he has 5 textboxes to display the words. So you can use String.Split()
;
Example:
string str="abc,xyz,asdf,qwer,mni";
textbox1.Text = str.Split(',')[0];
textbox2.Text = str.Split(',')[1];
textbox3.Text = str.Split(',')[2];
textbox4.Text = str.Split(',')[3];
textbox5.Text = str.Split(',')[4];
OR
You can use an array:
string[] strarray = str.Split(',');
textbox1.Text = strarray[0];
textbox2.Text = strarray[1];
textbox3.Text = strarray[2];
textbox4.Text = strarray[3];
textbox5.Text = strarray[4];
You do not need Split here, Just replace the comma in the string, string.Replace
Edit