void col_CellResize(object sender, CellResizeEventArgs e)
        {
            DunaGridHeaderCell resized_col = (DunaGridHeaderCell)sender;

            if (e.CellResizeSide == CellResizeEventArgs.ResizeSide.Left)
            {
                DunaGridHeaderCell prev_resized_col = null; //predchozi

                int index = this.Controls.IndexOf(resized_col);

                if (index > 0)
                {
                    prev_resized_col = (DunaGridHeaderCell)this.Controls[index - 1];
                }

                if (prev_resized_col.IsElastic)
                {
                }
                else
                {
                    prev_resized_col.Width -= prev_resized_col.Location.X + prev_resized_col.Width - resized_col.Location.X;
                }
            }
            else
            {
            }
            if (!this.disable_elastics)
            {
                this.countElasticColumnsWidth();
            }
            this.DeleteColumnGaps();
        }
        void col_CellResizeStart(object sender, CellResizeEventArgs e)
        {
            DunaGridHeaderCell cell = (DunaGridHeaderCell)sender;

            if (cell.IsElastic)
            {
                this.disable_elastics = true; //tady to tak jednoduchy nebude
            }
        }
        private DunaGridHeaderCell CreateCell(int x, IColumn c)
        {
            DunaGridHeaderCell col = new DunaGridHeaderCell(c);

            col.Height           = this.Height;
            col.Location         = new Point(x, 0);
            col.CellResize      += new CellResizeEventHandler(col_CellResize);
            col.CellResizeStart += new CellResizeEventHandler(col_CellResizeStart);
            col.CellResizeEnd   += new CellResizeEventHandler(col_CellResizeEnd);
            col.Orientation      = Orientation.Horizontal;
            return(col);
        }
        void column_WidthChanged(object sender, EventArgs e)
        {
            IColumn col = (IColumn)sender;

            foreach (object o in this.Controls)
            {
                if (o is DunaGridHeaderCell)
                {
                    DunaGridHeaderCell cell = (DunaGridHeaderCell)o;

                    if (cell.Name == col.Name)
                    {
                        cell.Refresh();
                    }
                }
            }

            OnNeedResize();
        }
        protected void DeleteColumnGaps()
        {
            int x = -this.movex;

            int pinned_width = GetPinnedColsWidth();

            x += pinned_width;
            this.SuspendLayout();
            foreach (object o in this.Controls)
            {
                if (o is DunaGridHeaderCell)
                {
                    DunaGridHeaderCell col = (DunaGridHeaderCell)o;
                    if (!col.Pinned)
                    {
                        col.Location = new Point(x, 0);
                        x           += col.Width;
                        col.Refresh();
                    }
                }
            }
            this.ResumeLayout();
        }
 private DunaGridHeaderCell CreateCell(int x, IColumn c)
 {
     DunaGridHeaderCell col = new DunaGridHeaderCell(c);
     col.Height = this.Height;
     col.Location = new Point(x, 0);
     col.CellResize += new CellResizeEventHandler(col_CellResize);
     col.CellResizeStart += new CellResizeEventHandler(col_CellResizeStart);
     col.CellResizeEnd += new CellResizeEventHandler(col_CellResizeEnd);
     col.Orientation = Orientation.Horizontal;
     return col;
 }
        protected void CreateCells()
        {
            this.Controls.Clear();

            int x   = 0;
            int ctr = 0;

            if (this.columns != null)
            {
                int pinned_width = GetPinnedColsWidth();

                x += pinned_width;

                bool prev_elastic = false;

                //vytvori nepripinovane

                foreach (IColumn c in this.columns)
                {
                    DunaGridHeaderCell col = CreateCell(x, c);

                    if (ctr == 0)
                    {
                        col.EnableLeftResize = false;
                        col.PositionInRow    = AbstractSystemHeader.cellPosition.first;
                    }
                    else if (ctr == this.columns.Count - 1)
                    {
                        col.PositionInRow = AbstractSystemHeader.cellPosition.last;
                        if (col.IsElastic)
                        {
                            col.EnableRightResize = false;
                        }
                    }
                    else
                    {
                        col.PositionInRow = AbstractSystemHeader.cellPosition.middle;
                    }

                    if (prev_elastic)
                    {
                        prev_elastic         = false;
                        col.IsPrevColElastic = true;
                    }
                    if (col.IsElastic)
                    {
                        prev_elastic = true;
                    }
                    this.Controls.Add(col);
                    x += c.Width;
                    ctr++;
                    col.Pinned = false;
                }

                //vytvori pripinovane
                foreach (IColumn c in this.columns.getPinnedColumns())
                {
                    x = 0;
                    DunaGridHeaderCell col = CreateCell(x, c);
                    col.PositionInRow = AbstractSystemHeader.cellPosition.middle;
                    this.Controls.Add(col);
                    col.Pinned = true;
                    col.BringToFront();
                    x += col.Width;
                }
            }
        }