Example #1
0
        private void FrmStaffList_Load(object sender, EventArgs e)
        {
            dgvStaff.DataSource = StaffDao.ListAllStaff();
            dgvStaff.ColumnHeadersDefaultCellStyle.Font =
                new Font("Time News Roman", 14, FontStyle.Bold);
            dgvStaff.DefaultCellStyle.Font = new Font("Khmer OS System", 12);
            dgvStaff.Columns["ID"].Visible = false;
            dgvStaff.Columns["Name"].Width = 200; //define column width
            dgvStaff.Columns["Salary"].DefaultCellStyle.Format   = "c";
            dgvStaff.Columns["HireDate"].DefaultCellStyle.Format = "dd/MM/yyyy";
            dgvStaff.Columns["StopDate"].DefaultCellStyle.Format = "dd/MM/yyyy";

            //define image size stretch
            DataGridViewImageColumn img = new DataGridViewImageColumn();

            img             = (DataGridViewImageColumn)dgvStaff.Columns["Photo"];
            img.ImageLayout = DataGridViewImageCellLayout.Stretch;
            foreach (DataGridViewColumn col in dgvStaff.Columns)
            {
                col.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            //dgvStaff.ClearSelection(); //clear select item in datagridview
        }