Ejemplo n.º 1
0
        //control the current cell
        void gridGroupingControl1_TableControlCurrentCellActivated(object sender, GridTableControlEventArgs e)
        {
            // Retrieve the current element
            Element el = GetNestedCurrentElement();

            if (el != null)
            {
                Record r = el.GetRecord();
                // current field.
                if (r != null)
                {
                    GridTable table = (GridTable)r.ParentDetails.ParentChildTable.ParentTable;

                    FieldDescriptor fd = table.CurrentRecordManager.CurrentField;
                    if (fd != null)
                    {
                        this.lblCell.Text = r.GetValue(fd.Name).ToString();

                        // TableCellStyle
                        GridTableCellStyleInfo style = table.GetTableCellStyle(r, fd);
                        this.lblCell.Text += " (" + style.ToString().Replace('\n', ';') + ")";

                        GridTableCellStyleInfoIdentity identity = style.TableCellIdentity;

                        // you can check identity for more information about cell.
                    }
                }
                // Record
                this.lblElement.Text = el.ToString();
            }
        }
Ejemplo n.º 2
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            if (DpiAware.GetCurrentDpi() > 96)
            {
                this.CaptionBarHeight = (int)DpiAware.LogicalToDeviceUnits(this.CaptionBarHeight);
            }
            gridGroupingControl1 = new GridGroupingControl();
            // now assign the datasource
            gridGroupingControl1.DataSource = table;
            SampleCustomization();
            GridSettings();

            Console.WriteLine(GridPropertyTypeDefaultStyleCollection.Default["System.Boolean"].Style);

            // enable/disable UITYpeEditors for boolean cells only and show checkbox instead.
            bool displayCheckBoxForBooleanFields = false;

            if (displayCheckBoxForBooleanFields)
            {
                GridPropertyTypeDefaultStyle booleanDefault = this.gridGroupingControl1.Engine.PropertyTypeDefaultStyles["System.Boolean"];
                booleanDefault.AllowDropDown = false;
            }

            #region Sample code to get the row and column index
            // Sample code to get the row and column index in the grid for a column (works also
            // if column sets with multiple rows are specified).
            bool useOldCodeToGetCellInfo = false;
            if (useOldCodeToGetCellInfo)
            {
                GridColumnDescriptor cd = this.gridGroupingControl1.TableDescriptor.Columns["Boolean"];
                int relativeRowIndex, colIndex;
                this.gridGroupingControl1.TableDescriptor.ColumnToRowColIndex(cd.MappingName, out relativeRowIndex, out colIndex);

                Record r = this.gridGroupingControl1.Table.Records[0];
                int    recordRowIndex = this.gridGroupingControl1.Table.DisplayElements.IndexOf(r);

                int rowIndex = recordRowIndex + relativeRowIndex;
                GridTableCellStyleInfo style = this.gridGroupingControl1.Table.GetTableCellStyle(rowIndex, colIndex + this.gridGroupingControl1.TableDescriptor.GetColumnIndentCount());

                Console.WriteLine(style.TableCellIdentity.ToString());
                Console.WriteLine(style.ToString());
            }
            else
            {
                // Newer code using new GetTableCellStyle overloads after version 3.0.0.16
                Record r = this.gridGroupingControl1.Table.Records[0];
                GridTableCellStyleInfo style = this.gridGroupingControl1.Table.GetTableCellStyle(r, "Boolean");

                Console.WriteLine(style.TableCellIdentity.ToString());
                Console.WriteLine(style.ToString());
            }
            #endregion
        }