string[] strArr = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "A", "B", "C", "D", "E", "F", "21", "22", "23", "24", "25", "26", "27", "2", "3", "4", "5", "6", "7", "8", "9", "10", "A", "B", "C", "D", "2", "3", "4", "5", "6", "7", "8", "9", "10", "A", "B", "C", "D", "2", "3", "4", "5", "6", "7", "8", "9", "10", "A", "B", "C", "D", "2", "3", "4", "5", "6", "7", "8", "9", "10" };private void CreateColumnRow() { DataTable data = new DataTable(); data.Columns.Add("1"); data.Columns.Add("2"); data.Columns.Add("3"); data.Columns.Add("4"); data.Columns.Add("5"); for (int i = 0; i < strArr.Length / 5; i++) { DataRow dr = data.NewRow(); data.Rows.InsertAt(dr, 0); } int intSub = strArr.Length % 5; if (intSub > 0) { DataRow dr = data.NewRow(); data.Rows.InsertAt(dr, 1); } radGridView1.DataSource = data; radGridView1.Columns[0].Width = 100; radGridView1.Columns[1].Width = 100; radGridView1.Columns[2].Width = 100; radGridView1.Columns[3].Width = 100; radGridView1.Columns[4].Width = 100; } private void Form1_Load(object sender, EventArgs e) { CreateColumnRow(); loadCheckBox(); } private void loadCheckBox(){ int z = 0; for (int i = 0; i < radGridView1.RowCount; i++) { for (int j = 0; j < radGridView1.ColumnCount; j++) { radGridView1.Rows[i].IsCurrent = true; radGridView1.Columns[j].IsCurrent = true; if (radGridView1.CurrentColumn.Index == j && radGridView1.CurrentRow.Index == i) { RadCheckBoxElement check = null; if (radGridView1.CurrentCell.Children.Count == 0) { check = new RadCheckBoxElement(); while (z < strArr.Length) { check.Name = "check_" + strArr[z]; check.Text = strArr[z]; radGridView1.CurrentCell.Children.Add(check); z++; break; } } else { check = (RadCheckBoxElement)radGridView1.CurrentCell.Children[0]; } } if (z == strArr.Length) { break; } } if (z == strArr.Length) { break; } } radGridView1.Rows[0].IsCurrent = true; radGridView1.Columns[0].IsCurrent = true;}Hello all person in forum!
I send a picture. In picture, i write problem error me. You view my code, you will see code of ( string[] strArr ). If I add ( strArr.lengh < 30 ), this code run OK. Else, it will be problem.
Help me fix it ! Thanks all !