private void button1_Click(object sender, EventArgs e) { dbContext = new BusinessDataBaseEntities(); CBDepartment.ItemCheck += CBDepartment_ItemCheck; var q = from b in dbContext.BulletinBoards join d in dbContext.Departments on b.DepartmentID equals d.departmentID join g in dbContext.Groups on b.GroupID equals g.GroupID join em in dbContext.Employees on b.EmployeeID equals em.employeeID select new { 部門 = d.name, 組別 = g.GroupName, 姓名 = em.EmployeeName, 留言內容 = b.Content, 張貼時間 = b.PostTime }; dataGridView1.DataSource = q.OrderByDescending(o => o.張貼時間).ToList(); dgvFormat(dataGridView1); CBDepartment.SetItemChecked(0, true); CBDepartment.SetItemChecked(1, true); CBDepartment.SetItemChecked(2, true); CBDepartment.SetItemChecked(3, true); CBDepartment.SetItemChecked(4, true); CBGroup.SetItemChecked(0, true); CBGroup.SetItemChecked(1, true); //this.dataGridView1.Update(); //this.dataGridView1.Refresh(); }
private void BulletinBoard_Load(object sender, EventArgs e) { for (int i = 0; i < DepartmentArr.Length; i++) { CCBoxItem item = new CCBoxItem(DepartmentArr[i], i); CBDepartment.Items.Add(item); } // If more then 5 items, add a scroll bar to the dropdown. CBDepartment.MaxDropDownItems = 5; // Make the "Name" property the one to display, rather than the ToString() representation. CBDepartment.DisplayMember = "Name"; CBDepartment.ValueSeparator = ", "; // Check the first 2 items. CBDepartment.SetItemChecked(0, true); CBDepartment.SetItemChecked(1, true); CBDepartment.SetItemChecked(2, true); CBDepartment.SetItemChecked(3, true); CBDepartment.SetItemChecked(4, true); //ccb.SetItemCheckState(1, CheckState.Indeterminate); if (CBDepartment.CheckedIndices.Contains(1)) { for (int i = 0; i < GroupArr.Length; i++) { CCBoxItem item2 = new CCBoxItem(GroupArr[i], i); CBGroup.Items.Add(item2); } // If more then 5 items, add a scroll bar to the dropdown. CBGroup.MaxDropDownItems = 3; // Make the "Name" property the one to display, rather than the ToString() representation. CBGroup.DisplayMember = "Name"; CBGroup.ValueSeparator = ", "; // Check the first 2 items. CBGroup.SetItemChecked(0, true); CBGroup.SetItemChecked(1, true); //ccb.SetItemCheckState(1, CheckState.Indeterminate); } }