Re: [.NET] datagrid+checkbox
※ 引述《hgm (豬豬)》之銘言:
: 在下用datagrid來讀取文字檔裡的值
: 想在每一筆資料前加checkbox,
: 結果在讀進資料時,卻被資料蓋到checkbox的欄位
: 試了很久,始終都無法將資料固定在checkbox後面
: 希望各位前輩能指點迷津
以下是我的程式碼部分
string filepath = textBox2.Text;
TextFieldParser newTextFieldParser = new
TextFieldParser(filepath);//讀取檔案
newTextFieldParser.TextFieldType = FieldType.Delimited;//內容為字
元分隔
newTextFieldParser.Delimiters = new string[] { "," };//以逗號區隔
string[] currentRow;
int myRowcount = 1;
int myColcount = 0;
//循環處理資料列的欄位值
while (!newTextFieldParser.EndOfData)
{
try
{
currentRow = newTextFieldParser.ReadFields();
if (myRowcount == 0)
{
foreach (string currentField in currentRow)
{
dataGridView1.ColumnCount = myColcount+1;//動態設
定控制項欄位數
myColcount += 1;
}
}
else
{
this.dataGridView1.Rows.Add(currentRow);
}
}
catch (MalformedLineException ex)
{
MessageBox.Show(ex.Message);
}
myRowcount += 1;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.243.159.5
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):