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


C# GridView.GetSelectedRows方法代码示例

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


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

示例1: 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

示例2: GetSelectedChannels

 private List<ChannelInfo> GetSelectedChannels(GridView gview)
 {
     var channels = new List<ChannelInfo>();
       foreach (int rowHandle in gview.GetSelectedRows())
       {
     if (gview.IsDataRow(rowHandle))
       channels.Add((ChannelInfo)gview.GetRow(rowHandle));
       }
       return channels;
 }
开发者ID:Morphipapa,项目名称:ChanSort,代码行数:10,代码来源:MainForm.cs

示例3: CreateBusinessMenu

        public static void CreateBusinessMenu(
            GridView gridViewMaster,
            DevExpress.XtraBars.BarSubItem barSubItem1,
            string fieldName,
            string[] captions,
            string[] ImageNames,
            DelegationLib.CallFunction_MulIn_NoOut[] delegates,
            PermissionItem[] pers)
        {
            if (captions == null)
            {
                //barSubItem1.Enabled = false;
                barSubItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                return;
            }

            int index = 0;
            foreach (string s in captions)
            {
                //Start Check Permission
                if (pers != null)
                {
                    if (pers[index] != null)
                    {
                        if (ApplyPermissionAction.checkPermission(pers[index]) == null ||
                            ApplyPermissionAction.checkPermission(pers[index]) == false)
                        {
                            index++;
                            continue;
                        }
                    }
                }
                //End Check Permission

                DevExpress.XtraBars.BarButtonItem temp = new DevExpress.XtraBars.BarButtonItem();
                temp.Caption = captions[index];
                temp.Name = index.ToString();
                if (!ImageNames[index].Equals(""))
                {
                    temp.Glyph = ResourceMan.getImage16(ImageNames[index]);
                }
                temp.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph;
                temp.ItemClick += delegate(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
                {
                    if (gridViewMaster.SelectedRowsCount < 1)
                    {
                        HelpMsgBox.ShowNotificationMessage("Vui lòng chọn dữ liệu !");
                        return;
                    }
                    //Lấy danh sách các giá trị (row[fieldName]) đang chọn
                    List<object> objs = new List<object>();
                    foreach (int i in gridViewMaster.GetSelectedRows())
                    {
                        DataRow row = gridViewMaster.GetDataRow(i);
                        objs.Add(row[fieldName]);
                    }

                    //Chọn xử lý tương ứng với chọn lựa
                    delegates[HelpNumber.ParseInt32(e.Item.Name)](objs);
                };

                barSubItem1.ItemLinks.Add(temp);
                index++;
            }
            //Không có chọn lựa ẩn luôn.
            if (barSubItem1.ItemLinks == null || barSubItem1.ItemLinks.Count == 0)
                barSubItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
        }
开发者ID:khanhdtn,项目名称:my-fw-win,代码行数:68,代码来源:PhieuQuanLyUtil.cs

示例4: GetDragData

        SchedulerDragData GetDragData(GridView view)
        {
            int[] selection = view.GetSelectedRows();
            if (selection == null)
                return null;

            AppointmentBaseCollection appointments = new AppointmentBaseCollection();
            int count = selection.Length;
            for (int i = 0; i < count; i++) {
                int rowIndex = selection[i];
                Appointment apt = schedulerStorage1.CreateAppointment(AppointmentType.Normal);
                apt.Subject = "Programación de Visita Cliente " + (string)view.GetRowCellValue(rowIndex, "NombreCliente");
                apt.LabelId = (int)Entidades.Enums.Enums.VisitaEstadoVista.Pendiente; // (int)view.GetRowCellValue(rowIndex, "Severity");
                apt.StatusId = 0; // (int)view.GetRowCellValue(rowIndex, "Priority");
                apt.Duration = new TimeSpan(0, 1, 0, 0); // TimeSpan.FromHours((int)view.GetRowCellValue(rowIndex, "Duration"));
                apt.Description = "Visita Cliente " + (string)view.GetRowCellValue(rowIndex, "NombreCliente");
                IdClienteDraw = (Int64)view.GetRowCellValue(rowIndex, "Id");
                appointments.Add(apt);
            }

            return new SchedulerDragData(appointments, 0);
        }
开发者ID:TarekMulla,项目名称:cra,代码行数:22,代码来源:frmCalendario.cs

示例5: GetTableOfSelectedRows

 public DataTable GetTableOfSelectedRows(GridView view)
 {
     DataTable resultTable = new DataTable();
     DataTable sourceTable = null;
     if (view.DataSource is DataView)
         sourceTable = ((DataView)view.DataSource).Table;
     else if (view.DataSource is BindingSource)
     {
         object dv = ((BindingSource)view.DataSource).List;
         sourceTable = ((DataView)dv).Table;
     }
     if (sourceTable != null)
     {
         resultTable = sourceTable.Clone();
         foreach (int rowHandle in view.GetSelectedRows())
         {
             DataRow row = view.GetDataRow(rowHandle);
             resultTable.Rows.Add(row.ItemArray);
         }
         resultTable.AcceptChanges();
     }
     return resultTable;
 }
开发者ID:rehman922,项目名称:VIRETAIL,代码行数:23,代码来源:GridCheckMarksSelection.cs

示例6: GetSelectRows

 private DataRow[] GetSelectRows(GridView gridView)
 {
     return Array.ConvertAll<int, DataRow>(gridView.GetSelectedRows(),
         new Converter<int, DataRow>(gridView.GetDataRow));
 }
开发者ID:khanhdtn,项目名称:my-office-manager,代码行数:5,代码来源:frmPhanQuyenNhanVienTaiNguyen.cs

示例7: DeleteSelectRows

 private void DeleteSelectRows(GridView gridView)
 {
     if (gridView.SelectedRowsCount == 0) return;
     int bfFocus = gridView.GetSelectedRows()[0];
     if (xtraTabControlPhanQuyen.SelectedTabPage == xtraTabPageTaiNguyen)
     {
         MSXoaTaiNguyen(gridView.SelectedRowsCount);
     }
     else
     {
         MSXoaNhomTaiNguyen(gridView.SelectedRowsCount);
     }
     gridView.DeleteSelectedRows();
     if (gridView.RowCount > 0)
     {
         if (gridView.GetNextVisibleRow(bfFocus) < 0
             && gridView.GetPrevVisibleRow(bfFocus) >= 0)
         {
             bfFocus--;
         }
         gridView.SelectRow(bfFocus);
         gridView.FocusedRowHandle = bfFocus;
     }
     ((DataTable)gridView.GridControl.DataSource).AcceptChanges();
 }
开发者ID:khanhdtn,项目名称:my-office-manager,代码行数:25,代码来源:frmPhanQuyenNhanVienTaiNguyen.cs

示例8: GetSelectedObjects

 IList GetSelectedObjects(GridView focusedView) {
     int[] selectedRows = focusedView.GetSelectedRows();
     if ((selectedRows != null) && (selectedRows.Length > 0)) {
         IEnumerable<object> objects = selectedRows.Where(rowHandle => rowHandle > -1).Select(focusedView.GetRow).Where(obj => obj != null);
         return objects.ToList();
     }
     return new List<object>();
 }
开发者ID:krazana,项目名称:eXpand,代码行数:8,代码来源:XpandGridListEditor.cs

示例9: SaveSelectionViewInfo

 public void SaveSelectionViewInfo(GridView view)
 {
     SaveSelList.Clear();
     GridColumn column = view.Columns[descriptor.keyFieldName];
     RowInfo rowInfo;
     int[] selectionArray = view.GetSelectedRows();
     if (selectionArray != null)  // otherwise we have a single focused but not selected row
         for (int i = 0; i < selectionArray.Length; i++)
         {
             int dataRowHandle = selectionArray[i];
             rowInfo.level = view.GetRowLevel(dataRowHandle);
             if (dataRowHandle < 0) // group row
                 dataRowHandle = view.GetDataRowHandleByGroupRowHandle(dataRowHandle);
             rowInfo.Id = view.GetRowCellValue(dataRowHandle, column);
             SaveSelList.Add(rowInfo);
         }
     rowInfo.Id = view.GetRowCellValue(view.FocusedRowHandle, column);
     rowInfo.level = view.GetRowLevel(view.FocusedRowHandle);
     SaveSelList.Add(rowInfo);
 }
开发者ID:Solnake,项目名称:kayflow,代码行数:20,代码来源:RefreshHelperClass.cs

示例10: UnselectAll

        //public static void GridInsertEnable(GridControl dxGrid)
        //{
        //    ((GridView)dxGrid.MainView).OptionsView.ShowNewItemRow = true;
        //    dxGrid.EmbeddedNavigator.Buttons.Append.Enabled = true;
        //}
        #endregion

        #region //GridInsertDisable
        //public static void GridInsertDisable(GridControl dxGrid)
        //{
        //    SaveCurrentChange(dxGrid);
        //    ((GridView)dxGrid.MainView).OptionsView.ShowNewItemRow = false;
        //    dxGrid.EmbeddedNavigator.Buttons.Append.Enabled = false;
        //}
        #endregion

        #region UnselectAll
        public static void UnselectAll(GridView view)
        {
            int[] iRows = view.GetSelectedRows();
            if (iRows == null) return;
            foreach (int iRow in iRows) view.UnselectRow(iRow);
        }
开发者ID:labeuze,项目名称:source,代码行数:23,代码来源:cGrid.cs


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