Пример #1
0
        public static DataRow GetSelectRow(DevExpress.XtraEditors.PopupContainerEdit popedit, int Viewindex)
        {
            try
            {
                DevExpress.XtraGrid.GridControl         grid   = (DevExpress.XtraGrid.GridControl)popedit.Properties.PopupControl.Controls[Viewindex];
                DevExpress.XtraGrid.Views.Grid.GridView myView = (DevExpress.XtraGrid.Views.Grid.GridView)grid.Views[Viewindex];

                int iRow = myView.FocusedRowHandle;

                if (iRow < 0)
                {
                    return(null);
                }

                int SourceIndex = myView.GetDataSourceRowIndex(iRow);

                DataRow r = ((DataTable)grid.DataSource).Rows[SourceIndex];

                return(r);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            switch (Convert.ToInt32(radioGroup1.EditValue))
            {
            case 1:     // solution 1
                if (cellStyles != null)
                {
                    int column = e.Column.AbsoluteIndex;
                    int row    = gridView1.GetDataSourceRowIndex(e.RowHandle);
                    AppearanceObject cellAppearance = cellStyles[new Point(column, row)] as AppearanceObject;
                    if (cellAppearance != null)
                    {
                        e.Appearance.Assign(cellAppearance);
                    }
                }
                break;

            case 2:     // solution 2
                string cellValue = gridView1.GetRowCellDisplayText(e.RowHandle, e.Column);
                if (cellValue.IndexOf('1') > 0)
                {
                    e.Appearance.BackColor = Color.Red;
                }
                break;
            }
        }
Пример #3
0
        /// <summary>
        /// 그리드에서 셀 값이 변경되었을 경우
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs"/> instance containing the event data.</param>
        private void ZAAI01_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                if (this.gridProject.FocusedView.Name != "GridView0")
                {
                    return;
                }

                if (e.Value.ToString() == "Y")
                {
                    DevExpress.XtraGrid.Views.Grid.GridView g = (DevExpress.XtraGrid.Views.Grid.GridView)gridProject.FocusedView;
                    int rowindex = g.GetDataSourceRowIndex(e.RowHandle);

                    string projectid = Convert.ToString(g.GetRowCellValue(rowindex, "PROJECT_ID"));
                    string level     = Convert.ToString(g.GetRowCellValue(rowindex, "PROJECT_LEVEL"));

                    DataRow[] r = dsProjects.Tables["dtProjectRole_Detail"].Select("PROJECT_ID    = '" + projectid + "' AND " +
                                                                                   "PROJECT_LEVEL <> '" + level + "' AND " +
                                                                                   "USE_YN        = 'Y' ");

                    for (int j = 0; j < r.Length; j++)
                    {
                        r[j]["USE_YN"] = "N";
                    }


                    this.gridProject.Refresh();
                    Basic.SetCursor(this, true);
                }
            }
            catch (Exception ex)
            {
                Basic.SetCursor(this, true);
                throw ex;
            }
        }
        private void GlobalGridView_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
        {
            var selectedRowHandles = GlobalGridView.GetSelectedRows();

            _selectedDataSourceRowIndeces = selectedRowHandles.Select(x => GlobalGridView.GetDataSourceRowIndex(x)).ToList();
        }
Пример #5
0
        private void GetColumnsName(DevExpress.XtraGrid.GridControl grd, ref string col1, ref string col2, int iloop)
        {
            try
            {
                int cnt = 0;

                DataTable dttmp = new DataTable();

                if (grd.MainView is DevExpress.XtraGrid.Views.Grid.GridView)
                {
                    DevExpress.XtraGrid.Views.Grid.GridView view = grd.MainView as DevExpress.XtraGrid.Views.Grid.GridView;
                    view.OptionsPrint.ExpandAllDetails = true;

                    if (view.RowCount > 0 || grd.DataSource != null)
                    {
                        DataTable dtSource = grd.DataSource as DataTable;
                        dttmp = dtSource.Clone();
                        for (int u = 0; u < view.RowCount; u++)
                        {
                            int iRow = view.GetDataSourceRowIndex(u);
                            dttmp.ImportRow(dtSource.Rows[iRow]);
                        }
                    }

                    for (int i = 0; i < view.Columns.Count; i++)
                    {
                        if (view.Columns[i].Visible && cnt == 0)
                        {
                            col1 = view.Columns[i].Caption;
                            cnt++;
                        }
                        else if (view.Columns[i].Visible && cnt > 0)
                        {
                            col2 = view.Columns[i].Caption;
                            cnt++;
                            break;
                        }
                    }
                }
                else if (grd.MainView is DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView)
                {
                    DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView view = grd.MainView as DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView;
                    view.OptionsPrint.ExpandAllDetails = true;

                    if (view.RowCount > 0 || grd.DataSource != null)
                    {
                        DataTable dtSource = grd.DataSource as DataTable;
                        dttmp = dtSource.Clone();
                        for (int u = 0; u < view.RowCount; u++)
                        {
                            int iRow = view.GetDataSourceRowIndex(u);
                            dttmp.ImportRow(dtSource.Rows[iRow]);
                        }
                    }

                    for (int i = 0; i < view.Columns.Count; i++)
                    {
                        if (view.Columns[i].Visible && cnt == 0)
                        {
                            col1 = view.Columns[i].Caption;
                            cnt++;
                        }
                        else if (view.Columns[i].Visible && cnt > 0)
                        {
                            col2 = view.Columns[i].Caption;
                            cnt++;
                            break;
                        }
                    }
                }
                else if (grd.MainView is DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)
                {
                    DevExpress.XtraGrid.Views.BandedGrid.BandedGridView view = grd.MainView as DevExpress.XtraGrid.Views.BandedGrid.BandedGridView;
                    view.OptionsPrint.ExpandAllDetails = true;

                    if (view.RowCount > 0 || grd.DataSource != null)
                    {
                        DataTable dtSource = grd.DataSource as DataTable;
                        dttmp = dtSource.Clone();
                        for (int u = 0; u < view.RowCount; u++)
                        {
                            int iRow = view.GetDataSourceRowIndex(u);
                            dttmp.ImportRow(dtSource.Rows[iRow]);
                        }
                    }

                    for (int i = 0; i < view.Columns.Count; i++)
                    {
                        if (view.Columns[i].Visible && cnt == 0)
                        {
                            col1 = view.Columns[i].Caption;
                            cnt++;
                        }
                        else if (view.Columns[i].Visible && cnt > 0)
                        {
                            col2 = view.Columns[i].Caption;
                            cnt++;
                            break;
                        }
                    }
                }
                else if (grd.MainView is DevExpress.XtraGrid.Views.Card.CardView)
                {
                    DevExpress.XtraGrid.Views.Card.CardView view = grd.MainView as DevExpress.XtraGrid.Views.Card.CardView;


                    if (view.RowCount > 0 || grd.DataSource != null)
                    {
                        DataTable dtSource = grd.DataSource as DataTable;
                        dttmp = dtSource.Clone();
                        for (int u = 0; u < view.RowCount; u++)
                        {
                            int iRow = view.GetDataSourceRowIndex(u);
                            dttmp.ImportRow(dtSource.Rows[iRow]);
                        }
                    }

                    for (int i = 0; i < view.Columns.Count; i++)
                    {
                        if (view.Columns[i].Visible && cnt == 0)
                        {
                            col1 = view.Columns[i].Caption;
                            cnt++;
                        }
                        else if (view.Columns[i].Visible && cnt > 0)
                        {
                            col2 = view.Columns[i].Caption;
                            cnt++;
                            break;
                        }
                    }
                }
                dttmp.TableName = iloop.ToString().Trim();
                this.ds.Tables.Add(dttmp.Copy());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }