예제 #1
0
        private void btnSort_Click(object sender, EventArgs e)
        {
            if (this.dgv.CurrentCell == null)
            {
                return;
            }

            string focused_compnam = (string)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Cells[this.col_compnam.Name].Value;

            if (this.sort_type == SORT_TYPE.COMPCOD)
            {
                this.sccomp_list    = new BindingList <SccompDbfVM>(DbfTable.GetSccompList().ToViewModel().OrderBy(s => s.compnam).ToList());
                this.dgv.DataSource = this.sccomp_list;
                this.sort_type      = SORT_TYPE.COMPNAM;

                var selected_row = this.dgv.Rows.Cast <DataGridViewRow>().Where(r => (string)r.Cells[this.col_compnam.Name].Value == focused_compnam).FirstOrDefault();
                if (selected_row != null)
                {
                    selected_row.Cells[this.dgv.FirstDisplayedScrollingColumnIndex].Selected = true;
                }
                return;
            }

            if (this.sort_type == SORT_TYPE.COMPNAM)
            {
                this.sccomp_list    = new BindingList <SccompDbfVM>(DbfTable.GetSccompList().ToViewModel().OrderBy(s => s.compcod).ToList());
                this.dgv.DataSource = this.sccomp_list;
                this.sort_type      = SORT_TYPE.COMPCOD;

                var selected_row = this.dgv.Rows.Cast <DataGridViewRow>().Where(r => (string)r.Cells[this.col_compnam.Name].Value == focused_compnam).FirstOrDefault();
                if (selected_row != null)
                {
                    selected_row.Cells[this.dgv.FirstDisplayedScrollingColumnIndex].Selected = true;
                }
                return;
            }
        }
예제 #2
0
        private void DialogSelectComp_Load(object sender, EventArgs e)
        {
            this.sccomp_list = new BindingList <SccompDbfVM>(DbfTable.GetSccompList().ToViewModel());

            this.dgv.DataSource = this.sccomp_list;
        }