Пример #1
0
        private void MatchColumnLayout(MyGridView otherView)
        {
            bool otherIsDetail = otherView.ParentView != null && otherView.ParentView.Equals(this);
            var  viewInfo      = otherIsDetail ? (MyGridViewInfo)otherView.GetViewInfo() : (MyGridViewInfo)this.GetViewInfo();
            int  borderWidth   = viewInfo.ViewRects.Client.X - viewInfo.ViewRects.Bounds.X;

            otherView.BeginUpdate();
            if (OptionsView.AutoSynchronizeDetailsLayout == DetailsLayoutSynchronizationType.LayoutAndColumnOrder)
            {
                var matches = new List <Tuple <GridColumn, GridColumn> >();
                foreach (GridColumn column in this.Columns)
                {
                    GridColumn other = otherView.Columns[column.FieldName];
                    if (other == null)
                    {
                        continue;
                    }
                    matches.Add(new Tuple <GridColumn, GridColumn>(column, other));
                }
                bool madeChanges;
                do
                {
                    madeChanges = false;
                    foreach (var item in matches)
                    {
                        GridColumn column = item.Item1;
                        GridColumn other  = item.Item2;
                        if (column.VisibleIndex != other.VisibleIndex && column.VisibleIndex < otherView.VisibleColumns.Count)
                        {
                            other.VisibleIndex = -1;
                            other.VisibleIndex = column.VisibleIndex;
                            madeChanges        = true;
                        }
                    }
                } while(madeChanges);
            }
            if (otherIsDetail)
            {
                otherView.VisibleColumns[0].Width = this.VisibleColumns[0].Width - viewInfo.LevelIndent - (viewInfo.LevelIndent * this.GroupCount) - viewInfo.ViewRects.IndicatorWidth - borderWidth + (this.VisibleColumns[0].Fixed == FixedStyle.Left ? this.FixedLineWidth : 0);
            }
            else
            if (this.VisibleColumns[0] != null)
            {
                otherView.VisibleColumns[0].Width = this.VisibleColumns[0].Width + viewInfo.LevelIndent + (viewInfo.LevelIndent * otherView.GroupCount) + viewInfo.ViewRects.IndicatorWidth + borderWidth - (otherView.VisibleColumns[0].Fixed == FixedStyle.Left ? otherView.FixedLineWidth : 0);
            }
            for (int i = 1; i < otherView.VisibleColumns.Count; i++)
            {
                GridColumn column = this.VisibleColumns[i];
                if (column != null)
                {
                    otherView.VisibleColumns[i].Width = column.Width;
                }
            }
            otherView.EndUpdate();
        }
Пример #2
0
 private void MyGridView_MasterRowExpanded(object sender, CustomMasterRowEventArgs e)
 {
     if (!OptionsView.ColumnAutoWidth && OptionsView.AutoSynchronizeDetailsLayout != DetailsLayoutSynchronizationType.None)
     {
         MyGridView currentView = sender as MyGridView;
         var        view        = currentView.GetDetailView(e.RowHandle, e.RelationIndex) as MyGridView;
         if (view == null)
         {
             return;
         }
         UpdateDetailViewsLeftCoord();
         currentView.AutoSynchronizeDetailsColumnWidths();
     }
 }
Пример #3
0
        private void UpdateDetailViewsColumnWidths(MyGridView excludeView)
        {
            int rowHandle = GetVisibleRowHandle(TopRowIndex);
            int rowIndex  = TopRowIndex;

            while (rowHandle != GridControl.InvalidRowHandle)
            {
                for (int i = 0; i < GetRelationCount(rowHandle); i++)
                {
                    var detailView = GetDetailView(rowHandle, i) as MyGridView;
                    if (detailView != null && detailView != excludeView)
                    {
                        MatchColumnLayout(detailView);
                        if (detailView is MyGridView)
                        {
                            (detailView as MyGridView).AutoSynchronizeDetailsColumnWidths();
                        }
                    }
                }
                rowIndex  = GetNextVisibleRow(rowIndex);
                rowHandle = GetRowHandle(rowIndex);
            }
        }
 public MyGridViewInfo(MyGridView gridView)
     : base(gridView)
 {
 }