public void loadDSTour() { dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("Tên Tour"); dt.Columns.Add("Mã Loại Tour"); listTour = DalTour.getAllTour(); foreach (Tour tour in listTour) { dt.Rows.Add(tour.Id, tour.Ten, tour.MaLoaiTour); } dv = new DataView(dt); dataGridView1.DataSource = dv; dataGridView1.Refresh(); dataGridView1.Update(); dataGridView1.AutoGenerateColumns = false; // dataGridView1.Columns["DoanDLs"].Visible = false; // dataGridView1.Columns.Remove("DoanDLs"); comboBox1.Items.Clear(); List <String> ColNameList = new List <String>(); ColNameList.Add("Tất cả"); int i = 1; foreach (DataColumn c in dt.Columns) { ColNameList.Add(c.ColumnName); /*if(i++ >= 3) * { * break; * }*/ } String[] ColNameArray = ColNameList.ToArray(); comboBox1.Items.AddRange(ColNameArray); if (comboBox1.Items.Count > 0) { comboBox1.SelectedIndex = 0; } // curTour = (listTour != null) ? listTour[0] : null; }
void LoadTour() { listTour = DalTour.getAllTour(); foreach (Tour tour in listTour) { cbTour.Items.Add(tour.Id + ". " + tour.Ten.Trim()); } try { // cbTour.SelectedIndex = 0; } catch (Exception e) { } }