rowspan in radgridview for winform

2 posts, 1 answers
  1. Vishal
    Vishal avatar
    10 posts
    Member since:
    Sep 2012

    Posted 17 Nov 2012 Link to this post

    Hi,

    How to have rowspan in radgridview for winform; i basically need to achieve below mentioned functionality using radgridview winform.

    col1 col2 col3 col4 col5
    1 a   1 a
    2 b 2 b
    3 c 3 c
    4 d 4 d
    5 e 5 e
    6 f 6 f
    7 g 7 g
    8 h 8 h
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    Hello Vishal,

    Please take a look at the following example:
    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using Telerik.WinControls.UI;
     
    public partial class Form1 : Form
    {
        private RadGridView grid = new RadGridView();
     
        public Form1()
        {
            InitializeComponent();
            grid.Dock = DockStyle.Fill;
            grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            grid.EnableFiltering = true;
            grid.DataBindingComplete += grid_DataBindingComplete;
     
            this.Controls.Add(grid);
        }
     
        private void grid_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
        {
        }
     
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
     
            var list = new List<GridDataSource>();
            for (int i = 0; i < 10; i++)
            {
                list.Add(new GridDataSource(string.Format("{0}{1}{0}{1}{0}{1}{0}", "a", Environment.NewLine)));
            }
            grid.AutoSizeRows = true;
            grid.DataSource = list;
        }
    }
     
    public class GridDataSource
    {
        public string Col1 { get; set; }
     
        public string Col2 { get; set; }
     
        public string Col3 { get; set; }
     
        public string Col4 { get; set; }
     
        public string Col5 { get; set; }
     
        public GridDataSource(string name)
        {
            this.Col1 = name + 1;
            this.Col2 = name + 2;
            this.Col3 = name + 3;
            this.Col4 = name + 4;
            this.Col5 = name + 5;
        }
    }


    If it not actually rowspan, but you can display wrapped info in rows like this.

    As far as i know rowspan is not possible at this time, but from your example i don't really understand what you want, please try to provide some more info on this one and i will do my best to help.

    Best Regards,
    Emanuel Varga
    WinForms MVP

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top