我的输入字符串是VALVE,GATE,SH_NAME:VLV,GATE,VLV_NOM_SIZE:4-1/16IN
我想要这样的输出(我希望在datagridview中输出)
COLUMN_1 COLUMN_2
VALVE
GATE
SH_NAME VLV
GATE
VLV_NOM_SIZE 4-1/16IN
答案 0 :(得分:2)
string str = "VALVE,GATE,SH_NAME:VLV,GATE,VLV_NOM_SIZE:4-1/16IN";
string[] Rows = str.Split(',');
dataGridView1.Columns.Add("Column1", "Column1");
dataGridView1.Columns.Add("Column2", "Column2");
foreach (string AddRow in Rows)
{
string[] Row = AddRow.Split(':');
dataGridView1.Rows.Add(Row);
}