示例#1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates an exact copy of this row.
        /// </summary>
        /// <returns>
        /// An <see cref="T:System.Object"></see> that represents the cloned
        /// <see cref="T:System.Windows.Forms.DataGridViewRow"></see>.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public override object Clone()
        {
            DataGridViewControlRow row = base.Clone() as DataGridViewControlRow;

            row.m_FillWeight = m_FillWeight;
            row.m_fAutoFill  = m_fAutoFill;
            return(row);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adjusts the row weight based on the new height of the row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// ------------------------------------------------------------------------------------
        private void AdjustRowWeight(DataGridViewControlRow row)
        {
            if (!row.IsAutoFill || VisibleRowCount == 1)
            {
                return;
            }

            // user changed the height of the row, so we have to adjust the weight of the cell.
            float rowPercentage = (float)row.Height / AvailableHeight;

            if (rowPercentage >= 1.0f)
            {
                // This row occupies all available space. Hide all other rows.
                foreach (DataGridViewControlRow otherRow in Rows)
                {
                    if (otherRow != row)
                    {
                        otherRow.Height  = 0;
                        otherRow.Visible = false;
                    }
                }
                return;
            }

            float otherRowWeights = 0;

            foreach (DataGridViewControlRow otherRow in Rows)
            {
                if (otherRow == row || !otherRow.IsAutoFill || !otherRow.Visible)
                {
                    continue;
                }
                otherRowWeights += otherRow.FillWeight;
            }
            row.FillWeight = otherRowWeights * rowPercentage / (1 - rowPercentage);
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adjusts the row weight based on the new height of the row.
		/// </summary>
		/// <param name="row">The row.</param>
		/// ------------------------------------------------------------------------------------
		private void AdjustRowWeight(DataGridViewControlRow row)
		{
			if (!row.IsAutoFill || VisibleRowCount == 1)
				return;

			// user changed the height of the row, so we have to adjust the weight of the cell.
			float rowPercentage = (float)row.Height / AvailableHeight;
			if (rowPercentage >= 1.0f)
			{
				// This row occupies all available space. Hide all other rows.
				foreach (DataGridViewControlRow otherRow in Rows)
				{
					if (otherRow != row)
					{
						otherRow.Height = 0;
						otherRow.Visible = false;
					}
				}
				return;
			}

			float otherRowWeights = 0;
			foreach (DataGridViewControlRow otherRow in Rows)
			{
				if (otherRow == row || !otherRow.IsAutoFill || !otherRow.Visible)
					continue;
				otherRowWeights += otherRow.FillWeight;
			}
			row.FillWeight = otherRowWeights * rowPercentage / (1 - rowPercentage);
		}