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


C# DevExpress.GetRowCellValue方法代码示例

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


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

示例1: GridViewCheck

        public void GridViewCheck(DevExpress.XtraGrid.Views.Grid.GridView gridView, string p, int id)
        {
            if (p == "user")
            {
                List<Users> listRelated = new List<Users>();
                listRelated = WcfServiceLocator.Create<IUsersManage>().FindRelatedUsersForUserGroup(id); //找出和指定用户组关联的用户
                for (int i = 0; i < gridView.RowCount; i++)
                {
                    var check = listRelated.Exists(delegate(Users user)
                    {
                        if (user.id == (int)gridView.GetRowCellValue(i, "id")) return true;
                        return false;
                    });
                    gridView.SetRowCellValue(i, "isChecked", check);
                }

            }
            if (p == "role")
            {
                List<Users> listRelated = new List<Users>();
                listRelated = WcfServiceLocator.Create<IRoleManage>().findRelatedUser(id); //找出和指定角色关联的用户
                for (int i = 0; i < gridView.RowCount; i++)
                {
                    var check = listRelated.Exists(delegate(Users user)
                    {
                        if (user.id == (int)gridView.GetRowCellValue(i, "id")) return true;
                        return false;
                    });
                    gridView.SetRowCellValue(i, "isChecked", check);
                }

            }
            if (p == "rolewithgroup")
            {
                List<Group> listRelated = new List<Group>();
                listRelated = WcfServiceLocator.Create<IRoleManage>().findRelatedGroup(id); //找出和指定角色关联的用户
                for (int i = 0; i < gridView.RowCount; i++)
                {
                    var check = listRelated.Exists(delegate(Group group)
                    {
                        if (group.Id == (int)gridView.GetRowCellValue(i, "Id")) return true;
                        return false;
                    });
                    gridView.SetRowCellValue(i, "isChecked", check);
                }
            }
        }
开发者ID:gofixiao,项目名称:HYPDM_Pro,代码行数:47,代码来源:CommonMethod.cs

示例2: GetCount

        private int GetCount(DevExpress.XtraGrid.Views.Grid.GridView gv)
        {
            if (gv==null||gv.RowCount<=0)
            {
                return 0;
            }

            try
            {
                int Count = 0;
                for (int i = 0; i < gv.RowCount; i++)
                {

                    Count = Count + int.Parse(gv.GetRowCellValue(i, "COUNT").ToString());

                }

                return Count;
            }
            catch (System.Exception ex)
            {
                return 0;

            }
        }
开发者ID:shumaojie,项目名称:Packaging,代码行数:25,代码来源:Frm_Stat.cs

示例3: GetListColumnsVisible

 public static List<structColumn> GetListColumnsVisible(DevExpress.XtraGrid.Views.BandedGrid.BandedGridView _BandedGridView)
 {
     List<structColumn> ListColumns = new List<structColumn>();
     try
     {
         if (_BandedGridView != null)
         {
             for (int i = 0; i < _BandedGridView.Columns.Count; i++)
             {
                 if (_BandedGridView.Columns[i].Visible && _BandedGridView.Columns[i].GroupIndex < 0)
                 {
                     structColumn _structColumn = new structColumn();
                     _structColumn.Caption = _BandedGridView.Columns[i].Caption;
                     _structColumn.FieldName = _BandedGridView.Columns[i].Name + "_" + _BandedGridView.Columns[i].FieldName;
                     _structColumn.VisibleIndex = _BandedGridView.Columns[i].VisibleIndex;
                     _structColumn.IsNumber = false;
                     if (!Object.Equals(_BandedGridView.GetRowCellValue(0, _BandedGridView.Columns[i]), null))
                     {
                         if (SHARED.Libraries.StringHelper.IsNumber(_BandedGridView.GetRowCellValue(0, _BandedGridView.Columns[i]).ToString()))
                         {
                             _structColumn.IsNumber = true;
                         }
                     }
                     ListColumns.Add(_structColumn);
                 }
             }
             ListColumns = ListColumns.OrderBy(item => item.VisibleIndex).ToList();
         }
     }
     catch
     { }
     return ListColumns;
 }
开发者ID:quocdunginfo,项目名称:QuanLyTaiSan,代码行数:33,代码来源:ReportHelper.cs

示例4: FillDatasetFromGrid

        public static DataSet FillDatasetFromGrid(DevExpress.XtraGrid.Views.BandedGrid.BandedGridView _BandedGridView)
        {
            DataSet _DataSet = new DataSet();
            DataTable _DataTable = new DataTable();
            if (!Object.Equals(_BandedGridView, null))
            {
                foreach (GridColumn _GridColumn in _BandedGridView.Columns)
                {
                    _DataTable.Columns.Add(_GridColumn.Name + "_" + _GridColumn.FieldName, Nullable.GetUnderlyingType(_GridColumn.ColumnType) ?? _GridColumn.ColumnType);
                    if (!(_GridColumn.Visible && _GridColumn.GroupIndex < 0))
                    {
                        if (Object.Equals(_GridColumn.ColumnType, typeof(Int32)) || Object.Equals(_GridColumn.ColumnType, typeof(float)) || Object.Equals(_GridColumn.ColumnType, typeof(DateTime)))
                        {
                            _DataTable.Columns.Add(_GridColumn.Name + "_" + _GridColumn.FieldName + "_STRING", typeof(String));
                        }
                    }
                }
                for (int i = 0; i < _BandedGridView.DataRowCount; i++)
                {
                    DataRow _DataRow = _DataTable.NewRow();
                    foreach (GridColumn _GridColumn in _BandedGridView.Columns)
                    {
                        var Value = _BandedGridView.GetRowCellValue(i, _GridColumn);
                        if (Object.Equals(Value, null))
                        {
                            _DataRow[_GridColumn.Name + "_" + _GridColumn.FieldName] = DBNull.Value;
                        }
                        else
                        {
                            _DataRow[_GridColumn.Name + "_" + _GridColumn.FieldName] = _BandedGridView.GetRowCellValue(i, _GridColumn);
                        }

                        if (!(_GridColumn.Visible && _GridColumn.GroupIndex < 0))
                        {
                            if (Object.Equals(_GridColumn.ColumnType, typeof(Int32)) || Object.Equals(_GridColumn.ColumnType, typeof(float)) || Object.Equals(_GridColumn.ColumnType, typeof(DateTime)))
                            {
                                var Value_String = _BandedGridView.GetRowCellValue(i, _GridColumn);
                                if (Object.Equals(Value_String, null))
                                {
                                    _DataRow[_GridColumn.Name + "_" + _GridColumn.FieldName + "_STRING"] = "";
                                }
                                else
                                {
                                    _DataRow[_GridColumn.Name + "_" + _GridColumn.FieldName + "_STRING"] = _BandedGridView.GetRowCellValue(i, _GridColumn);
                                }
                            }
                        }
                    }
                    _DataTable.Rows.Add(_DataRow);
                }
            }
            _DataSet.Tables.Add(_DataTable);
            return _DataSet;
        }
开发者ID:quocdunginfo,项目名称:QuanLyTaiSan,代码行数:54,代码来源:ReportHelper.cs

示例5: ExportGridViewToExcel

        /// <summary>
        /// 可以自定义导出Excel的格式,传的参数为GridView
        /// </summary>
        /// <param name="gridView">需要保存的GridView</param>
        /// <param name="sheetName">Sheet名</param>
        /// <param name="filename">文件名</param>
        public static void ExportGridViewToExcel(DevExpress.XtraGrid.Views.Grid.GridView gridView, string sheetName, string filename)
        {
            //System.Data.DataTable dt = (System.Data.DataTable)gridView.DataSource;
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.FileName = filename;
            sfd.Filter = "Excel files (*xls) | *.xls";
            sfd.RestoreDirectory = true;

            if (sfd.ShowDialog() == DialogResult.OK && sfd.FileName.Trim() != null)
            {
                int colIndex = 0;
                System.Reflection.Missing miss = System.Reflection.Missing.Value;
                Microsoft.Office.Interop.Excel.Application xlapp = new Microsoft.Office.Interop.Excel.Application();
                xlapp.Visible = false; //是否显示导出过程 ,建议关闭,否则在导出过程中鼠标点击Excel文件时会出错。
                Microsoft.Office.Interop.Excel.Workbooks mBooks = (Microsoft.Office.Interop.Excel.Workbooks)xlapp.Workbooks;
                Microsoft.Office.Interop.Excel.Workbook mBook = (Microsoft.Office.Interop.Excel.Workbook)mBooks.Add(miss);
                Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)mBook.Worksheets.Add(miss, miss, 0, Microsoft.Office.Interop.Excel.XlSheetType.xlWorksheet);

                //设置文字自动换行 
                //mSheet.Cells.WrapText = true;
                try
                {

                    int gridViewIndex = 1;
                    int rowIndex = 1;
                    sheet.Name = sheetName;

                    //设置对齐方式
                    sheet.Cells.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    //设置第一行高度,即标题栏
                    ((Microsoft.Office.Interop.Excel.Range)sheet.Rows["1:1", System.Type.Missing]).RowHeight = 20;

                    //设置数据行行高度
                    ((Microsoft.Office.Interop.Excel.Range)sheet.Rows["2:" + gridView.RowCount + 1, System.Type.Missing]).RowHeight = 16;

                    //设置字体大小(10号字体)
                    sheet.Range[sheet.Cells[1, 1], sheet.Cells[gridView.RowCount + 1, gridView.Columns.Count]].Font.Size = 10;

                    //设置单元格边框
                    Microsoft.Office.Interop.Excel.Range range1 = sheet.Range[sheet.Cells[1, 1], sheet.Cells[gridView.RowCount + 1, gridView.Columns.Count]];

                    //写标题
                    for (int row = 1; row <= gridView.Columns.Count; row++)
                    {
                        sheet.Cells[1, row] = gridView.Columns[row - 1].GetTextCaption();
                    }
                    for (int i = 0; i < gridView.RowCount; i++)
                    {
                        rowIndex++;
                        colIndex = 0;
                        for (int j = 0; j < gridView.Columns.Count; j++)
                        {
                            colIndex++;
                            sheet.Cells[rowIndex, colIndex] = gridView.GetRowCellValue(i, gridView.Columns[j]);
                        }
                    }
                    gridViewIndex++;

                    mBook.SaveAs(sfd.FileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel7, miss, miss, miss, miss, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
                                 miss, miss, miss, miss, miss);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }

                finally
                {
                    mBooks.Close();
                    xlapp.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(mBook);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(mBooks);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(xlapp);
                    GC.Collect();
                }
            }
            else
            {
                //return false;
            }
        }
开发者ID:xlgwr,项目名称:producting,代码行数:88,代码来源:GridControlToExcel.cs

示例6: GetSelectedValues

 public object[] GetSelectedValues(DevExpress.XtraGrid.Views.Grid.GridView view, string fieldName)
 {
     int[] selectedRows = view.GetSelectedRows();
     object[] result = new object[selectedRows.Length];
     for (int i = 0; i < selectedRows.Length; i++)
     {
         int rowHandle = selectedRows[i];
         if (!gvMain.IsGroupRow(rowHandle))
         {
             result[i] = view.GetRowCellValue(rowHandle, fieldName);
         }
         else
             result[i] = -1;
     }
     return result;
 }
开发者ID:tofupl,项目名称:Csharp,代码行数:16,代码来源:ws.cs


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