Пример #1
0
        private void BuildGrids()
        {
            BuildGridColumns(uiDataBefore);
            uiDataBefore.Rows.Add(3);
            uiDataBefore.Rows[1].Cells[0].Value = "Original inputs (u(i))";
            uiDataBefore.Rows[2].Cells[0].Value = "Normalized inputs (x(i))";
            uiDataBefore.Rows[3].Cells[0].Value = "Weights (w(i))";
            BuildGridColumns(uiDataAfter);
            uiDataAfter.Rows.Add(1);
            uiDataAfter.Rows[1].Cells[0].Value = "Weights (w(i))";
            for (int i = 1; i <= _programLogic.ExaminedNeuron.Weights.Length; i++)
            {
                uiDataBefore.Rows[0].Cells[i].Value = i;
                uiDataAfter.Rows[0].Cells[i].Value  = i;
            }

            DataGridViewColumn firstCol1 = uiDataBefore.Columns[0];
            DataGridViewColumn firstCol2 = uiDataAfter.Columns[0];
            int width1 = firstCol1.GetPreferredWidth(
                DataGridViewAutoSizeColumnMode.AllCells, true);
            int width2 = firstCol2.GetPreferredWidth(
                DataGridViewAutoSizeColumnMode.AllCells, true);
            int maxWidth = Math.Max(width1, width2);

            firstCol1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            firstCol2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            firstCol1.Width        = maxWidth;
            firstCol2.Width        = maxWidth;
        }
Пример #2
0
        /// <summary>
        /// Sets the minimum width of a column such that at least the entire header text fits in the column.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <remarks>The column must already be added to a data grid view, otherwise the preferred
        /// size of the header cannot be determined (font etc. not known)</remarks>
        public static void SetMinimumWidthForHeader([NotNull] DataGridViewColumn column)
        {
            Assert.ArgumentNotNull(column, nameof(column));
            Assert.NotNull(column.DataGridView,
                           "column must be added to datagridview to calculate preferred width");

            const bool fixedHeight = true;
            int        headerWidth = column.GetPreferredWidth(
                DataGridViewAutoSizeColumnMode.ColumnHeader, fixedHeight);

            if (headerWidth > 0)
            {
                column.MinimumWidth = headerWidth;
            }
        }