当前位置: 首页>>代码示例>>C#>>正文


C# GridView类代码示例

本文整理汇总了C#中GridView的典型用法代码示例。如果您正苦于以下问题:C# GridView类的具体用法?C# GridView怎么用?C# GridView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GridView类属于命名空间,在下文中一共展示了GridView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractSummaryItems

		public static ArrayList ExtractSummaryItems(GridView view)
		{
			var items = new ArrayList();
			foreach (GridSummaryItem si in view.GroupSummary.Cast<GridSummaryItem>().Where(si => si is GridGroupSummaryItem && si.SummaryType != SummaryItemType.None))
				items.Add(si);
			return items;
		}
开发者ID:w01f,项目名称:VolgaTeam.SalesLibrary,代码行数:7,代码来源:GroupSummaryHelper.cs

示例2: btn1_Click

    protected void btn1_Click(object sender, EventArgs e)
    {
        ControlClass d = new ControlClass(txtAspContent.Text);
        List<p1> lst = new List<p1>();
        lst.Add(new p1 { Name = "hi1" });
        lst.Add(new p1 { Name = "hi2" });
        lst.Add(new p1 { Name = "hi3" });
        lst.Add(new p1 { Name = "hi4" });
        GridView ss = new GridView();
        ss = ((GridView)d.ControlGenerated);
        ss.DataSource = lst;
        ss.DataBind();

        foreach (GridViewRow row in ss.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                Label myHyperLink = row.FindControl("lbl1") as Label;
                Label myHyperLnk1 = row.FindControl("Name2") as Label;
            }
        }

        foreach (GridViewRow row in gg1.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                Label myHyperLink = row.FindControl("lbl1") as Label;
            }
        }

        plcHolder1.Controls.Add(ss);
    }
开发者ID:hiprafoo,项目名称:NoMoreGooglingGridview,代码行数:32,代码来源:NoMoreGooglingGridView.aspx.cs

示例3: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // set our layout to be the home screen
            SetContentView(Resource.Layout.DataGridExampleScreen);

            gridView = FindViewById<GridView> (Resource.Id.offerGridView);

            var txtTitle = FindViewById<TextView> (Resource.Id.txtTitle);
            var txtAddColumn = FindViewById<TextView> (Resource.Id.txtAddColumn);
            var txtAddRow = FindViewById<TextView> (Resource.Id.txtAddRow);

            txtTitle.SetText ("Data Grid Example", TextView.BufferType.Normal);

            txtAddColumn.Click += (sender, e) => {
                dataTable.Columns.Add("New Col " + (dataTable.Columns.Count + 1));
                gridView.NumColumns = dataTable.Columns.Count;
                gridView.InvalidateViews();
            };
            txtAddRow.Click += (sender, e) => {
                var row = dataTable.NewRow();
                dataTable.Rows.Add(row);
                gridView.InvalidateViews();
            };
        }
开发者ID:robertpi,项目名称:AndroidDataGridExample,代码行数:26,代码来源:DataGridExampleScreen.cs

示例4: CreateDM_NHAN_VIEN

 public GridColumn[] CreateDM_NHAN_VIEN(GridControl gridControl, GridView gridView)
 {
     XtraGridSupportExt.TextLeftColumn(
         XtraGridSupportExt.CreateGridColumn(gridView, "ID", -1, -1), "ID");
     XtraGridSupportExt.TextLeftColumn(
         XtraGridSupportExt.CreateGridColumn(gridView, "Mã nhân viên", 0, 150), "MA_NV");
     GridColumn Ten = XtraGridSupportExt.CreateGridColumn(gridView, "Tên nhân viên", 1, 150);
     XtraGridSupportExt.TextLeftColumn(
         Ten, "NAME");
     GridColumn ColPhongBan = XtraGridSupportExt.CreateGridColumn(gridView, "Tên phòng ban", 2, 150);
     ColPhongBan.FieldName = "DEPARTMENT_ID";
     //XtraGridSupportExt.IDGridColumn(ColPhongBan, "ID", "NAME", "DEPARTMENT", "DEPARTMENT_ID");
     HelpGridColumn.CotCombobox(ColPhongBan, HelpDB.getDatabase().LoadDataSet(@"SELECT *
                                     FROM DEPARTMENT WHERE PARENT_ID IS NOT NULL"), "ID", "NAME", "DEPARTMENT_ID");
     ColPhongBan.OptionsColumn.AllowEdit = true;
     ColPhongBan.OptionsColumn.AllowFocus = false;
     ColPhongBan.OptionsColumn.ReadOnly = true;
     Ten.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
     XtraGridSupportExt.TextLeftColumn(
         XtraGridSupportExt.CreateGridColumn(gridView, "CMND", 3, 150), "CMND");
     XtraGridSupportExt.DateTimeGridColumn(
         XtraGridSupportExt.CreateGridColumn(gridView, "Ngày sinh", 4, 150), "NGAY_SINH");
     XtraGridSupportExt.TextLeftColumn(
         XtraGridSupportExt.CreateGridColumn(gridView, "Điện thoại", 5, 150), "DIEN_THOAI");
     XtraGridSupportExt.TextLeftColumn(
         XtraGridSupportExt.CreateGridColumn(gridView, "Địa chỉ", 6, 150), "DIA_CHI");
     XtraGridSupportExt.TextLeftColumn(
         XtraGridSupportExt.CreateGridColumn(gridView, "Email", 7, 150), "EMAIL");
     HelpGridColumn.CotCheckEdit(
         XtraGridSupportExt.CreateGridColumn(gridView, "Hiển thị", 8, 100), "VISIBLE_BIT");
     gridView.OptionsView.ShowGroupedColumns = false;
     gridView.HorzScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Always;
     gridView.OptionsView.ColumnAutoWidth = true;
     return null;
 }
开发者ID:khanhdtn,项目名称:my-office-manager,代码行数:35,代码来源:frmAddEmployee.cs

示例5: UpdateTempSub

    public override void UpdateTempSub(GridView dgv)
    {
        DataTable dt1 = (DataTable)ViewState[FormID + "_Edit_" + dgv.ID];
        if (dt1.Rows.Count == 0)
        {
            return;
        }
        DataRow dr;
        for (int i = 0; i < dgv.Rows.Count; i++)
        {
            dr = dt1.Rows[i + dgv.PageSize * dgv.PageIndex];
            dr.BeginEdit();

            dr["BillID"] = this.txtID.Text.Trim();
            dr["RowID"] = ((Label)dgv.Rows[i].FindControl("RowID")).Text;
            dr["ProductCode"] = ((TextBox)dgv.Rows[i].FindControl("ProductCode")).Text;
            dr["ProductName"] = ((TextBox)dgv.Rows[i].FindControl("ProductName")).Text;
            dr["Quantity"] = ((TextBox)dgv.Rows[i].FindControl("Quantity")).Text;
            dr["Weight"] = ((TextBox)dgv.Rows[i].FindControl("Weight")).Text.Trim() == "" ? 0 : decimal.Parse(((TextBox)dgv.Rows[i].FindControl("Weight")).Text.Trim());
            dr["Barcode"] = ((TextBox)dgv.Rows[i].FindControl("Barcode")).Text;
            dr["Memo"] = ((TextBox)dgv.Rows[i].FindControl("SubMemo")).Text;
            dr.EndEdit();
        }
        dt1.AcceptChanges();

        object o = dt1.Compute("SUM(Quantity)", "");
        this.txtTotalQty.Text = o.ToString();
        ViewState[FormID + "_Edit_" + dgv.ID] = dt1;
    }
开发者ID:haipingma,项目名称:CL_WMCS,代码行数:29,代码来源:OutStockEdit.aspx.cs

示例6: BestFitMasterColumns

 /// <summary>Chỉnh độ rộng của cột theo dạng đẹp nhất có thể
 /// </summary>
 public static void BestFitMasterColumns(GridView gridView)
 {
     gridView.GridControl.Load += delegate(object sender, EventArgs e)
     {
         gridView.BestFitColumns();
     };
 }
开发者ID:khanhdtn,项目名称:my-office-manager,代码行数:9,代码来源:PLGUIUtil.cs

示例7: OutputExcel

    /// <summary>
    /// 輸出為Excel
    /// </summary>
    /// <param name="webpage">傳入目前網頁Page變數</param>
    /// <param name="Dt">需要匯出的內容</param>
    /// <param name="FilePath">輸出的檔名</param>
    public void OutputExcel(Page webpage,
                            DataTable Dt,
                            string FilePath
                            )
    {
        GridView gvExport = new GridView();
        gvExport.DataSource = Dt;
        gvExport.DataBind();

        string UTF8FileName = HttpUtility.UrlEncode(FilePath,
                                                    System.Text.Encoding.UTF8
                                                    );
        webpage.Response.Clear();
        webpage.Response.AddHeader("content-disposition",
                                   string.Format("attachment;filename={0}",
                                                 UTF8FileName)
                                   );

        webpage.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        webpage.Response.ContentType = "application/vnd.ms-excel";
        webpage.Response.Charset = "big5";

        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        gvExport.RenderControl(htmlWrite);
        webpage.Response.Write(stringWrite.ToString().Replace("<div>", "").Replace("</div>", ""));
        webpage.Response.End();
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:34,代码来源:ExcelExportHelper.cs

示例8: frmClipboardItem

 public frmClipboardItem(string entity, GridView dgv)
 {
     InitializeComponent();
     ds = ((DataView)dgv.DataSource).Table.DataSet;
     gridControlDetails.DataSource = ClipboardMan.Instance.clipboard[entity].Data.Tables[0];
     Entity = entity;
 }
开发者ID:khanhdtn,项目名称:my-fw-win,代码行数:7,代码来源:TrialfrmClipboardItem.cs

示例9: AddContextMenu

        /// <summary>
        /// Thêm danh sách menu ngữ cảnh vào trong GridView.
        /// Menu này áp dụng khi click phải trên phần nội dung của lưới
        /// </summary>
        public static void AddContextMenu(GridView grid, List<ItemInfo> items)
        {
            BarManager manager = new BarManager(); ;
            PopupMenu menu = new PopupMenu();

            if (items == null) return;
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].Per != null)
                    if (ApplyPermissionAction.checkPermission(items[i].Per) == null ||
                       ApplyPermissionAction.checkPermission(items[i].Per) == false)
                    {
                        continue;
                    }

                Image image = ResourceMan.getImage16(items[i].Image);
                BarItem item = new BarButtonItem();
                item.Caption = items[i].Caption;
                item.Name = i.ToString();
                item.Glyph = image;
                manager.Items.Add(item);
                menu.ItemLinks.Add(manager.Items[i]);
                DelegationLib.CallFunction_MulIn_NoOut del = items[i].Delegates;
                item.ItemClick += delegate(object sender, ItemClickEventArgs e)
                {
                    string name = item.Name;
                    List<object> objs = new List<object>();

                    int[] a = grid.GetSelectedRows();
                    DataRow dr = grid.GetDataRow(a[0]);
                    objs.Add(dr);

                    del(objs);
                };
            }

            grid.MouseUp += delegate(object sender, MouseEventArgs e)
            {
                if ((e.Button & MouseButtons.Right) != 0 && grid.GridControl.ClientRectangle.Contains(e.X, e.Y))
                {
                    menu.ShowPopup(manager, Control.MousePosition);
                }
                else
                {
                    menu.HidePopup();
                }
            };

            grid.MouseMove += delegate(object sender, MouseEventArgs e)
            {
                if ((e.Button & MouseButtons.Right) != 0 && grid.GridControl.ClientRectangle.Contains(e.X, e.Y))
                {
                    menu.ShowPopup(manager, Control.MousePosition);
                }
                else
                {
                    menu.HidePopup();
                }
            };
        }
开发者ID:khanhdtn,项目名称:my-fw-win,代码行数:64,代码来源:HelpGrid.cs

示例10: GridViewQuickColumnCustomization

 public GridViewQuickColumnCustomization(GridView view)
 {
     this.view = view;
     View.CustomDrawRowIndicator += new RowIndicatorCustomDrawEventHandler(View_CustomDrawRowIndicator);
     View.MouseDown += new System.Windows.Forms.MouseEventHandler(View_MouseDown);
     View.MouseUp += new System.Windows.Forms.MouseEventHandler(View_MouseUp);
 }
开发者ID:incjonya,项目名称:demos,代码行数:7,代码来源:Class1.cs

示例11: AddCalcGridColum

 /// <summary>Phương thức cho phép thêm chức năng vào cho Cột
 /// Khi thay đổi giá trị của cột nó làm ảnh hưởng giá trị của các
 /// cột khác
 /// </summary>
 /// <param name="Column">Cột mã hàng</param>
 /// <param name="FieldName">FieldName của Tên hàng hóa, đơn giá, giảm giá ...</param>
 /// <param name="func">Hàm gán giá trị cho các field</param>
 public static void AddCalcGridColum(GridView Grid, GridColumn Column, string[] FieldNames, GetInfo Func)
 {
     Grid.CellValueChanged += delegate(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
     {
         try
         {
             GridView grid = (GridView)sender;
             DataRow row = grid.GetDataRow(grid.FocusedRowHandle);
             if (e.Column.FieldName.Equals(Column.FieldName))
             {
                 object[] Values = Func(row[Column.FieldName]);
                 if (Values != null)
                 {
                     for (int i = 0; i < FieldNames.Length; i++)
                     {
                         grid.SetRowCellValue(grid.FocusedRowHandle, FieldNames[i], Values[i]);
                     }
                 }
                 else
                 {
                     grid.DeleteRow(grid.FocusedRowHandle);
                 }
             }
         }
         catch (Exception ex)
         {
             PLException.AddException(ex);
         }
     };
 }
开发者ID:khanhdtn,项目名称:my-fw-win,代码行数:37,代码来源:RowInteraction.cs

示例12: GroupRows

 /// <summary> 
 /// 合并GridView中某列相同信息的行(单元格) 
 /// </summary> 
 /// <param name="GridView1">GridView</param> 
 /// <param name="cellNum">第几列</param> 
 public static void GroupRows(GridView grv, int cellNum)
 {
     // i行控制器
     int i = 0, rowSpanNum = 1;
     while (i < grv.Rows.Count - 1)
     {
         GridViewRow gvr = grv.Rows[i];
         for (++i; i < grv.Rows.Count; i++)
         {
             GridViewRow gvrNext = grv.Rows[i];
             if (gvr.Cells[cellNum].Text == gvrNext.Cells[cellNum].Text)
             {
                 gvrNext.Cells[cellNum].Visible = false;
                 rowSpanNum++;
             }
             else
             {
                 gvr.Cells[cellNum].RowSpan = rowSpanNum;
                 rowSpanNum = 1;
                 break;
             }
             if (i == grv.Rows.Count - 1)
             {
                 gvr.Cells[cellNum].RowSpan = rowSpanNum;
             }
         }
     }
 }
开发者ID:vinStar,项目名称:vin_zone_2009,代码行数:33,代码来源:GroupRows.aspx.cs

示例13: Create

        public static XtraGridControl Create(string name = null, DockStyle dockStyle = DockStyle.None, int? x = null, int? y = null, int? width = null, int? height = null)
        {
            XtraGridControl grid = new XtraGridControl();
            GridView gridView = new GridView();

            ((ISupportInitialize)grid).BeginInit();
            ((ISupportInitialize)gridView).BeginInit();

            grid.MainView = gridView;
            grid.Name = name;
            grid.Dock = dockStyle;
            grid.Font = new Font("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0);
            Point? point = zForm.GetPoint(x, y);
            if (point != null)
                grid.Location = (Point)point;
            Size? size = zForm.GetSize(width, height);
            if (size != null)
                grid.Size = (Size)size;
            //grid.TabIndex = 0;

            gridView.GridControl = grid;

            ((ISupportInitialize)grid).EndInit();
            ((ISupportInitialize)gridView).EndInit();

            return grid;
        }
开发者ID:labeuze,项目名称:source,代码行数:27,代码来源:XtraGridControl.cs

示例14: GridViewPrinter

        public GridViewPrinter(GridControl aGrid, PrintDocument aPrintDocument, GridView aTable)
        {
            TheDataGrid = aGrid;
            ThePrintDocument = aPrintDocument;
            TheTable = aTable;

            if (aPrintDocument.DefaultPageSettings.Landscape)
            {
                PageWidth = ThePrintDocument.DefaultPageSettings.PaperSize.Height;
                PageHeight = ThePrintDocument.DefaultPageSettings.PaperSize.Width;

                TopMargin = ThePrintDocument.DefaultPageSettings.Margins.Right;
                BottomMargin = ThePrintDocument.DefaultPageSettings.Margins.Left;
                LeftMargin = ThePrintDocument.DefaultPageSettings.Margins.Top;
                RightMargin = ThePrintDocument.DefaultPageSettings.Margins.Bottom;
            }
            else
            {
                PageWidth = ThePrintDocument.DefaultPageSettings.PaperSize.Width;
                PageHeight = ThePrintDocument.DefaultPageSettings.PaperSize.Height;

                TopMargin = ThePrintDocument.DefaultPageSettings.Margins.Top;
                BottomMargin = ThePrintDocument.DefaultPageSettings.Margins.Bottom;
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:25,代码来源:GridViewPrinter.cs

示例15: layout

 private void layout(ref GridView grid)
 {
     grid.ItemsSource = null;
     items = new ObservableCollection<Grid>();
     index = 0;
     numbers = select(1, 90, 90);
 }
开发者ID:RoguePlanetoid,项目名称:Windows-10-Universal-Windows-Platform,代码行数:7,代码来源:Library.cs


注:本文中的GridView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。