Re: [.NET] datagrid+checkbox

看板Visual_Basic作者 (豬豬)時間16年前 (2008/01/22 13:45), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《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
文章代碼(AID): #17bOCGuK (Visual_Basic)
文章代碼(AID): #17bOCGuK (Visual_Basic)