This is a migrated thread and some comments may be shown as answers.

rowspan in radgridview for winform

1 Answer 162 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vishal
Top achievements
Rank 1
Vishal asked on 18 Nov 2012, 02:07 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 19 Nov 2012, 11:13 AM
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

Tags
GridView
Asked by
Vishal
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Share this question
or