データグリッドを埋めるために使用する2列とMatchCollectionを持つdatagridviewがあります。最初の列のデータグリッドにmatchcollectionの最初の一致を挿入し、次に2番目の列のmatchcollectionの2番目の値を挿入できます。その後、新しい行が作成され、再び開始されます。MatchCollectionをdatagridviewに挿入するC#
このグリッドビューにはデータがバインドされていないため、データグリッドに挿入されているmatchCollectionがテーブルの他のものを上書きしないようにする必要があります。これどうやってするの?
これは、あなたがカスタムGridViewの列を作成し、DataGridViewTextBoxCellから継承することができます
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
line = line.Trim();
if (line.StartsWith("addTestingPageContentText"))
{
string temp;
string pattern = "\"([^\"]+)\"";
Regex r = new Regex(pattern);
MatchCollection regs = r.Matches(line);
foreach (Match reg in regs)
{
temp = reg.ToString();
temp = temp.Replace("\"", "");
int rowCount = contentTable_grd.Rows.Count - 1;
if (contentTable_grd.Rows[rowCount].Cells[0].Value == null)
contentTable_grd.Rows[rowCount].Cells[0].Value = temp;
else
contentTable_grd.Rows[rowCount].Cells[1].Value = temp;
contentTable_grd.Rows.Add();
}
}
}
のWinFormやASP.NETを試してみてください? – Peyman
@peyman winforms –