本文整理汇总了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();
}
};
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例6: GetSelectRows
private DataRow[] GetSelectRows(GridView gridView)
{
return Array.ConvertAll<int, DataRow>(gridView.GetSelectedRows(),
new Converter<int, DataRow>(gridView.GetDataRow));
}
示例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();
}
示例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>();
}
示例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);
}
示例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);
}