Home Forums WinForms controls Xceed Grid for WinForms Editors content vertical alignment

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17430 |

    Hello,

    I am making some tries on the layout of your controls using your trial.

    In order to space my grid’s rows content more than default, I increased the “Height” in the Datarowtemplate and set the “VerticalAlignment” to “center”.

    This works fine. Data are showed at the center of the row and rows are taller, with the effect of more “breathe” between rows.

    The problem is when the user enter “editmode” in a cell. The text get vertical aligned to the top, I suppose that’s because of the default vertical alignment in the associated editor. Although I did not notice a “VerticalAlignment” property to change for the editor content.

    How can I center the editors content VerticalAlignment? Or is there another way to have more “breathe” between rows?

    I need to know that I can apply a basic layout variant to your controls without too much trouble before buying.

    Thank you for your courtesy

    Federico Innocenti

    Imported from legacy forums. Posted by F. (had 974 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Frederico,

    To keep the content vertically centered even in edition, you could use the following code sample.

     

    Example:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Xceed.Grid;
    using Xceed.Grid.Editors;
    using Xceed.Editors;
    using Xceed.Grid.Viewers;

    namespace _26771
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                Xceed.Grid.Licenser.LicenseKey = “”;
                InitializeComponent();

                Column column0 = new Column(“Test”, typeof(string));
                this.grid.Columns.Add(column0);
                this.grid.DataRowTemplate.Height = 50;
                this.grid.DataRowTemplate.OverrideUIStyle = true;
                this.grid.DataRowTemplate.VerticalAlignment = VerticalAlignment.Center;
                CellEditorManager cellEditorManager = this.grid.Columns[“Test”].CellEditorManager;
                
                WinTextBox winTextBox = cellEditorManager.TemplateControl as WinTextBox;
                cellEditorManager.QueryEditorBounds += new QueryEditorBoundsEventHandler(cellEditorManager_QueryEditorBounds);
                for (int i = 0; i < 100; ++i)
                {
                    Xceed.Grid.DataRow row = this.grid.DataRows.AddNew();
                    row.Cells[“Test”].Value = i.ToString();
                }
            }

            void cellEditorManager_QueryEditorBounds(object sender, QueryEditorBoundsEventArgs e)
            {
                TextEditor textEditor = sender as TextEditor;
                e.Bounds = new Rectangle(e.Bounds.X, e.Bounds.Y + (e.Bounds.Height – ((WinTextBox)e.Control).TextBoxArea.PreferredHeight) / 2, e.Bounds.Width, e.Bounds.Height);
            }
        }
    }

    Imported from legacy forums. Posted by Mohamed [Xceed] (had 1068 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.