2
A
回答
0
你不需要在這裏拆分,只需更換逗號在字符串中,string.Replace
str = str.Replace(",", " ");
編輯
string []arr = str.Split('c');
txt1.Text = arr[0];
txt2.Text = arr[1];
txt3.Text = arr[2];
txt4.Text = arr[3];
txt5.Text = arr[4];
0
先用空格替換逗號:
str = str.Replace(',', '');
然後將其添加回文本框:
textbox.Text = str;
0
OP說,他有5個文本框來顯示的話。所以你可以使用String.Split()
;
例子:
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
您可以使用數組:
string[] strarray = str.Split(',');
textbox1.Text = strarray[0];
textbox2.Text = strarray[1];
textbox3.Text = strarray[2];
textbox4.Text = strarray[3];
textbox5.Text = strarray[4];
相關問題
- 1. TSQL拆分逗號分隔字符串
- 2. 拆分逗號分隔字符串/值
- 3. 拆分逗號分隔的字符串
- 4. 拆分逗號分隔字符串
- 5. 拆分逗號分隔的字符串,但忽略逗號整個字
- 6. 轉換被逗號分隔值,以逗號分隔字符串
- 7. 逗號分隔符號字符串
- 8. 搜索逗號IDS分隔字符串以逗號分隔字符串
- 9. 逗號分隔字符串分割
- 10. 分離逗號分隔的字符串
- 11. 拆分逗號分隔字符串(PHP +正則表達式)
- 12. 拆分逗號分隔字符串得到「」
- 13. 如何在Oracle中拆分逗號分隔的字符串
- 14. SQL:用查詢拆分逗號分隔的字符串列表?
- 15. 如何拆分用逗號分隔的字符串?
- 16. 拆分逗號分隔字符串錶行到使用TSQL
- 17. 拆分逗號分隔字符串中的Bash
- 18. 拆分逗號分隔字符串轉換成排在MySQL
- 19. 拆分逗號分隔的多個字符串在C#
- 20. 將逗號分隔的字符串拆分爲列
- 21. 拆分逗號分隔字符串來算重複
- 22. 拆分字段的逗號分隔值
- 23. 包含逗號與逗號分隔符的分割字符串
- 24. 將逗號分隔的字符串拆分爲較小的字符串
- 25. 拆分逗號分隔字符串,字符串中丟棄一些值
- 26. 帶逗號的分割字符串也會拆分&符號
- 27. 逗號分隔字符串表
- 28. 比較逗號分隔字符串
- 29. 逗號分隔字符串比較
- 30. 逗號分隔字符串列表
所以,在總共三個問題:我如何從一個DataGridView列數據(你是說細胞)?如何在TextBox中設置文本?如何替換字符串中的逗號?沒有代碼,只顯示很少的努力... Winforms? – spender
@Brain:爲了在5個不同的文本框中顯示它,你可以使用'Split()'。看到我的答案。 –