Ejemplo n.º 1
0
        public bool CanMergeCells(GridStyleInfo style1, GridStyleInfo style2)
        {
            GridStyleInfoIdentity id1 = style1.CellIdentity;
            GridStyleInfoIdentity id2 = style2.CellIdentity;

            if (id1.RowIndex < 1 || id2.RowIndex < 1)
            {
                return(false);
            }

            //			if (id1.ColIndex > 0 && id2.ColIndex > 0
            //				&& !CanMergeCells(this[id1.RowIndex, id1.ColIndex-1], this[id2.RowIndex, id2.ColIndex-1]))
            //				return false;

            return(style1.Text != "" && style1.Text == style2.Text);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Here you can can compare cells if they meet the criteria for
        /// automatic merging. You could also consider neighbouring columns
        /// as part of the criteria if necessary.
        /// </summary>
        /// <param name="style1"></param>
        /// <param name="style2"></param>
        /// <returns></returns>
        protected override void OnQueryCanMergeCells(GridQueryCanMergeCellsEventArgs e)
        {
            base.OnQueryCanMergeCells(e);

            if (!e.Handled)
            {
                GridStyleInfoIdentity id1 = e.Style1.CellIdentity;
                GridStyleInfoIdentity id2 = e.Style2.CellIdentity;

                if (id1.ColIndex <= 3)
                {
                    e.Result  = CanMergeCells(e.Style1, e.Style2);
                    e.Handled = true;
                }
                // for other cells (Col 4 and higher) we just do default handling
            }
        }