久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

DEV GridControl小結(jié),。,。

 但見群鷗日日來 2012-05-29

1,、 如何解決單擊記錄整行選中的問題

View->OptionsBehavior->EditorShowMode 設(shè)置為:Click

 

2,、 如何新增一條記錄

(1)、gridView.AddNewRow()

(2),、實(shí)現(xiàn) gridView_InitNewRow 事件

 

3,、如何解決 GridControl 記錄能獲取而沒有顯示出來的問題

gridView.populateColumns();

 

4、如何讓行只能選擇而不能編輯(或編輯某一單元格)

(1),、View->OptionsBehavior->EditorShowMode 設(shè)置為:Click

(2),、View->OptionsBehavior->Editable 設(shè)置為:false

 

5、如何禁用 GridControl 中單擊列彈出右鍵菜單

設(shè)置 Run Design->OptionsMenu->EnableColumnMenu 設(shè)置為:false

 

6,、如何隱藏 GridControl 的 GroupPanel 表頭

設(shè)置 Run Design->OptionsView->ShowGroupPanel 設(shè)置為:false

 

7,、如何禁用 GridControl 中列頭的過濾器 過濾器如下圖所示:                               

設(shè)置 Run Design->OptionsCustomization->AllowFilter 設(shè)置為:false

 

8、如何在查詢得到 0 條記錄時(shí)顯示自定義的字符提示/顯示 如圖所示:



方法如下:

//When no Records Are Being Displayed

private void gridView1_CustomDrawEmptyForeground(object sender, CustomDrawEventArgs e)

{

 //方法一(此方法為GridView設(shè)置了數(shù)據(jù)源綁定時(shí),,可用)

 ColumnView columnView = sender as ColumnView;

BindingSource bindingSource = this.gridView1.DataSource as BindingSource;

if(bindingSource.Count == 0)

{

string str = "沒有查詢到你所想要的數(shù)據(jù)!";

Font f = new Font("宋體", 10, FontStyle.Bold);

Rectangle r = new Rectangle(e.Bounds.Top + 5, e.Bounds.Left + 5, e.Bounds.Right - 5, e.Bounds.Height - 5);

e.Graphics.DrawString(str, f, Brushes.Black, r); }

//方法二(此方法為GridView沒有設(shè)置數(shù)據(jù)源綁定時(shí),,使用,,一般使用此種方 法)

if (this._flag)

 { if (this.gridView1.RowCount == 0)

 { string str = "沒有查詢到你所想要的數(shù)據(jù)!"; Font f = new Font("宋體", 10, FontStyle.Bold);

Rectangle r = new Rectangle(e.Bounds.Left + 5, e.Bounds.Top + 5, e.Bounds.Width - 5, e.Bounds.Height - 5);

e.Graphics.DrawString(str, f, Brushes.Black, r); } } }

 

9、如何顯示水平滾動(dòng)條,?或

設(shè)置 this.gridView.OptionsView.ColumnAutoWidth = false;


.....列表寬度自適應(yīng)內(nèi)容

gridview1.BestFitColumns();

 

10,、如何定位到第一條數(shù)據(jù)/記錄?

設(shè)置 this.gridView.MoveFirst()

 

11,、如何定位到下一條數(shù)據(jù)/記錄,?
設(shè)置 this.gridView.MoveNext()

 

12、如何定位到最后一條數(shù)據(jù)/記錄,?

設(shè)置 this.gridView.MoveLast()

 

13,、設(shè)置成一次選擇一行,并且不能被編輯

this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;

 this.gridView1.OptionsBehavior.Editable = false;

this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;

 

 14,、如何顯示行號(hào),?
  private void gvPayList_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
            if (e.Info.IsRowIndicator)
            {
                if (e.RowHandle >= 0)
                {
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
                }
                else if (e.RowHandle < 0 && e.RowHandle > -1000)
                {
                    e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite;
                    e.Info.DisplayText = "G" + e.RowHandle.ToString();
                }
            }
        }

 

15、如何讓各列頭禁止移動(dòng),?

設(shè)置 gridView1.OptionsCustomization.AllowColumnMoving = false;

16,、如何讓各列頭禁止排序?

設(shè)置 gridView1.OptionsCustomization.AllowSort = false;

17,、如何禁止各列頭改變列寬?

設(shè)置 gridView1.OptionsCustomization.AllowColumnResizing = false;

 

18.拖動(dòng)滾動(dòng)條時(shí)固定某一列

設(shè)置Columns,,選擇要固定的列,。設(shè)置Fixed屬性,可以選擇:固定在左邊,、固定在右邊,、不固定。

19.獲取選定行,指定列單元格的內(nèi)容

      return gridView1.GetRowCellValue(pRows[0], ColumName).ToString ();

20.分組顯示

OptionsView>OptionsBehavior>AutoExpandAllGroups = True
選擇要分組的列,,將GroupIndex屬性設(shè)置為0

21.格式化數(shù)據(jù)

       private void gvList_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
        {
            if (this.gvList.FocusedColumn.FieldName == "passQty")
            {
                string passQty = e.Value.ToString().Trim();
                int receiveQty = orderDetailList[this.gvList.FocusedRowHandle].qty;
                if (!JXType.IsIntBigThanZero(passQty))
                {
                    e.Valid = false;
                    e.ErrorText = "合格數(shù)量必須為大于等于0小于等于接貨數(shù)量的整數(shù),!";
                }
                else
                {
                    if (int.Parse(passQty) > receiveQty)
                    {
                        e.Valid = false;
                        e.ErrorText = "合格數(shù)量必須為大于0小于等于接貨數(shù)量的整數(shù)!";
                    }
                }
            }

}


22.合并表頭

   ///初始化表格

using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraEditors.Repository;
        private void InitGrid()
        {
            // advBandedGridView1是表格上的默認(rèn)視圖,,注意這里聲明的是:BandedGridView
            BandedGridView view = advBandedGridView1 as BandedGridView;
            view.BeginUpdate(); //開始視圖的編輯,,防止觸發(fā)其他事件
            view.BeginDataUpdate(); //開始數(shù)據(jù)的編輯
            view.Bands.Clear();

            view.OptionsView.ShowColumnHeaders = false;                         //因?yàn)橛蠦and列了,所以把ColumnHeader隱藏
            //添加列標(biāo)題
      //添加列標(biāo)題
            GridBand bandID = view.Bands.AddBand("ID");
            bandID.Visible 
= false//隱藏ID列
            GridBand bandName = view.Bands.AddBand("姓名");
            GridBand bandSex 
= view.Bands.AddBand("性別");
            GridBand bandBirth 
= view.Bands.AddBand("出生日期");
            GridBand bandScore 
= view.Bands.AddBand("分?jǐn)?shù)");
            GridBand bandMath 
= bandScore.Children.AddBand("數(shù)學(xué)");
            GridBand bandChinese 
= bandScore.Children.AddBand("語文");
            GridBand bandEnglish 
= bandScore.Children.AddBand("英語");
            GridBand bandSubTotal 
= bandScore.Children.AddBand("小計(jì)");
            GridBand bandRemark 
= view.Bands.AddBand("備注");

            bandFile.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;//這是合并表頭居中顯示
            view.EndDataUpdate();//結(jié)束數(shù)據(jù)的編輯
            view.EndUpdate();   //結(jié)束視圖的編輯
        }


點(diǎn)擊打開鏈接



23.   //動(dòng)態(tài)添加列
            DevExpress.XtraGrid.Columns.GridColumn Col1 = new DevExpress.XtraGrid.Columns.GridColumn();
            Col1.FieldName = "name";
            Col1.Caption = "名字";
            Col1.Visible = false;
            Col1.VisibleIndex = gvCountry.Columns.Count;
            gvCountry.Columns.Add(Col1);


24,。設(shè)置自動(dòng)增加的行號(hào)

  private void gridview_CustomDrawRowIndicator(object sender,                            DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
    {

e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
            if (e.Info.IsRowIndicator)
            {
                if (e.RowHandle >= 0)
                {
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
                }
                else if (e.RowHandle < 0 && e.RowHandle > -1000)
                {
                    e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite;
                    e.Info.DisplayText = "G" + e.RowHandle.ToString();
                }
            }

25.特效:gridcontrol中有5種view 型式,,普通的是gridview,然后分別為cardview,、BandedView,、Advanced BandedView、LayoutView,;共5種,。

  1),、view組中把OptionView下的viewmode 設(shè)置成“Carousel”就達(dá)到這種“旋轉(zhuǎn)木馬”式的gridcontrol view 特效了
  2)、layoutView1.OptionsCarouselMode.PitchAngle 這個(gè)屬性決定“旋轉(zhuǎn)木馬”的pitch angle 螺距角; 螺旋角; 螺旋升角; 俯仰角; 傾角; 節(jié)錐半角 
  3),、Roll Angle 屬性決定著 傾側(cè)角度
  4),、指定數(shù)據(jù)源,顯示數(shù)據(jù):
  //顯示數(shù)據(jù)
        private void showData(List<Employee > list)
        {
            DataTable dt = new DataTable("OneEmployee");
            dt.Columns.Add("Caption", System.Type.GetType("System.String"));
            dt.Columns.Add("Department", System.Type.GetType("System.String"));
            dt.Columns.Add("PhotoName", System.Type.GetType("System.Byte[]"));

            for (int i = 0; i < list.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr["Caption"] = list[i].Name;
                dr["Department"] = list[i].Department;
                string imagePath = @"D:\C#\photos\" + list[i].PhotoPath;
                dr["PhotoName"] = getImageByte(imagePath);
                dt.Rows.Add(dr);
            }
            gridControl1.DataSource = dt;
        }

        //返回圖片的字節(jié)流byte[]
        private byte[] getImageByte(string imagePath)
        {
            FileStream files = new FileStream(imagePath, FileMode.Open);
            byte[] imgByte = new byte [files.Length ];
            files.Read(imgByte, 0, imgByte.Length);
            files.Close();
            return imgByte;
        }


26.檢查數(shù)據(jù)的有效性

  在gridview的ValidateRow事件中加入檢查代碼:
  #region 檢查數(shù)據(jù)
  private void gridView1_ValidateRow(object sender, ValidateRowEventArgs e)
  {
  GridView view = sender as GridView;
  view.ClearColumnErrors();

  if (view.GetRowCellValue(e.RowHandle, "ReceiveDate") == DBNull.Value)
  {
  e.Valid = false;
  view.SetColumnError(view.Columns["ReceiveDate"], "必須指定日期");
  }

  }


27.設(shè)某一列文字和標(biāo)題局中顯示                  
   gridView1.Columns[0].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
   gridView1.Columns[0].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;


28.列表過濾條件多選

列名.OptionsFilter.FilterPopupMode= DevExpress.XtraGrid.Columns.FilterPopupMode.CheckedList


29.隔行換色的方法


 this.gridView1.Appearance.OddRow.BackColor = Color.White;  // 設(shè)置奇數(shù)行顏色 // 默認(rèn)也是白色 可以省略 
this.gridView1.OptionsView.EnableAppearanceOddRow = true;   // 使能 // 和和上面綁定 同時(shí)使用有效 
this.gridView1.Appearance.EvenRow.BackColor = Color.WhiteSmoke; // 設(shè)置偶數(shù)行顏色 
this.gridView1.OptionsView.EnableAppearanceEvenRow = true;   // 使能 // 和和上面綁定 同時(shí)使用有效

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多