作者hgm (猪猪)
看板Visual_Basic
标题Re: [.NET] datagrid+checkbox
时间Tue Jan 22 13:45:51 2008
※ 引述《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