1. 程式人生 > >supergridcontrol記錄,分頁

supergridcontrol記錄,分頁

sqlserver分頁記錄

select top 50 DengJiBH,sSuoYouQuanShenQingRen,sZuoLuo,sQiuHao,sQuanHao,ChaXun_BianHao,rownumber,zZhuCeLXBH,sMianJi,gDengJiLXBH
from(
select row_number() over(order by isnull(Zi.DengJiBH,'00000000')) as rownumber, 
dj_DengJi.DengJiBH,dj_DengJi.sSuoYouQuanShenQingRen,Zi.sZuoLuo,Zi.sQiuHao,
Zi.sQuanHao,isnull(Zi.DengJiBH,'00000000') as ChaXun_BianHao,Zi.zZhuCeLXBH,Zi.sSuoYouQuanZH,zi.sMianJi,zi.gDengJiLXBH
from dj_DengJi 
left join dj_DengJi Zi on dj_DengJi.DengJiBH=Zi.zPiDengJiBH 
where dj_DengJi.gQuanLi=4 and dj_DengJi.gWanCheng<>1 
and dj_DengJi.sSuoYouQuanShenQingRen like '%鑫苑萬卓%' 
and Zi.sZuoLuo like '%高鐵新城%'
--and dj_DengJi.DengJiBH='151004824 '
) b
where rownumber>(50*(1-1)) order by rownumber

  

superGridControl 複製單元格文字:

        private void superGridControl2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
            {
                var pos = PointToClient(MousePosition);
                pos.Y -= this.superGridControl2.Parent.Location.Y;
                var cell = this.superGridControl2.PrimaryGrid.GetElementAt(pos.X, pos.Y);
                var col = this.superGridControl2.PrimaryGrid.GetColumnAt(pos);
                if (cell != null && col != null)
                {
                    var txt = (cell as GridRow).Cells[col].Value.ToString();
                    Clipboard.SetDataObject(txt, true);
                    ToastNotification.Show(this.Parent, "已複製" + txt, Xiang.Business.Properties.Resources.close_16px,
                       2000, eToastGlowColor.Blue, eToastPosition.TopCenter);
                }
            }
        }

  

顯示行頭序號,從1開始

this.superGridControl2.PrimaryGrid.ShowRowGridIndex = true;
this.superGridControl2.PrimaryGrid.RowHeaderIndexOffset = 1;

選中行物件:

GridRow row = this.superGridControl2.PrimaryGrid.GetSelectedRows().FirstOrDefault() as GridRow;
var arc = row.DataItem as ArchivementDto;

 

選中行按回車:

        private void superGridControl2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SelectedElementCollection col = this.superGridControl2.PrimaryGrid.GetSelectedRows();
                if (col.Count > 0)
                {
                    e.Handled = true;
                    GridRow row = col[0] as GridRow;
                    var item = row.DataItem as ApplySheetListDto;

                    var dlg = new ApplyDetailDialog(item.applyId);
                    var pos = PointToScreen(this.gridColumn3.LocationRelative);
                    dlg.Location = pos;
                    dlg.ShowDialog();
                }
            }
            else if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
            {
                var pos = PointToClient(MousePosition);
                pos.Y -= this.superGridControl2.Parent.Location.Y;
                var cell = this.superGridControl2.PrimaryGrid.GetElementAt(pos.X, pos.Y);
                var col = this.superGridControl2.PrimaryGrid.GetColumnAt(pos);
                if (cell != null && col != null)
                {
                    var txt = (cell as GridRow).Cells[col].Value.ToString();
                    Clipboard.SetDataObject(txt, true);
                    ToastNotification.Show(this.Parent, "已複製" + txt, Xiang.Business.Properties.Resources.close_16px,
                       2000, eToastGlowColor.Blue, eToastPosition.TopCenter);
                }
            }
        }

  

單個文字設定顏色:

        private void superGridControl1_GetCellStyle(object sender, GridGetCellStyleEventArgs e)
        {
            if (e.StyleType != StyleType.Default) { return; }

            var cell = e.GridCell as GridCell;
            if (cell == null) { return; }

            if (cell.Value.ToString() == "歷史")
            {
                e.Style.TextColor = Color.Red;
            }
        }