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

Self relation multi-select not working

1 Answer 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 05 May 2011, 12:42 AM
I've set the MultiSelect to true but I cannot select more than one row. Is this feature not available with a self-relation hierarchy gridview?

Being able to select more than one row is very important to the application I'm working on.

Thanks for your help.

1 Answer, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 05 May 2011, 10:01 AM
Hello Tim,

Using the latest version I am able to set and use MultiSelect under a Self Reference hierarchy RadGridView.
Please can you try the following exmaple and let me know if that works for you.

Designer File
namespace RadGridView_Hierarchy_CS
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components;
  
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
  
        #region Windows Form Designer generated code
  
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.radGridView1 = new Telerik.WinControls.UI.RadGridView();
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
            this.SuspendLayout();
            // 
            // radGridView1
            // 
            this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.radGridView1.Location = new System.Drawing.Point(0, 0);
            this.radGridView1.Name = "radGridView1";
            this.radGridView1.Size = new System.Drawing.Size(323, 320);
            this.radGridView1.TabIndex = 0;
            this.radGridView1.Text = "radGridView1";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(323, 320);
            this.Controls.Add(this.radGridView1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit();
            this.ResumeLayout(false);
  
        }
  
        #endregion
  
        private Telerik.WinControls.UI.RadGridView radGridView1;
    }
}

Form1.cs
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 Telerik.WinControls.UI;
  
  
namespace RadGridView_Hierarchy_CS
{
    public partial class Form1 : Form
    {
  
        private BindingList<Model> list = new BindingList<Model>();
  
        public Form1()
        {
            InitializeComponent();
  
            this.radGridView1.AutoGenerateColumns = false;
            this.radGridView1.AutoGenerateHierarchy = false;
  
            this.radGridView1.Columns.Add(new GridViewDecimalColumn("Id"));
            this.radGridView1.Columns.Add(new GridViewDecimalColumn("ParentId"));
            this.radGridView1.Columns.Add(new GridViewTextBoxColumn("Name"));
            this.radGridView1.Columns.Add(new GridViewTextBoxColumn("Value"));
            this.radGridView1.Columns.Add(new GridViewDecimalColumn("Units"));
  
  
            list.Add(new Model(1, 0, "Parent 1", "Value 1", 1));
            list.Add(new Model(2, 0, "Parent 2", "Value 2", 1));
            list.Add(new Model(3, 0, "Parent 3", "Value 3", 1));
  
            list.Add(new Model(4, 1, "Child 1", "Value 1", 1));
            list.Add(new Model(5, 2, "Child 2", "Value 2", 1));
            list.Add(new Model(6, 3, "Child 3", "Value 3", 1));
            list.Add(new Model(7, 1, "Child 4", "Value 1", 1));
            list.Add(new Model(8, 2, "Child 5", "Value 2", 1));
            list.Add(new Model(9, 3, "Child 6", "Value 3", 1));
  
        }
  
         
        private void Form1_Load(object sender, EventArgs e)
        {
            SetupRadGridviewRelation();
            this.radGridView1.DataSource = list;
  
            this.radGridView1.MultiSelect = true;
        }   
  
        private void SetupRadGridviewRelation()
        {
            this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "Id", "ParentId");
        }
  
    }
  
    public class Model
    {
        public Model() { }
  
        public Model(int id, int parentId, string name, string value, int units)
        { this.Id = id; this.ParentId = parentId; this.Name = name; this.Value = value; this.Units = units; }
  
        public int Id
        { get; set; }
  
        public int ParentId
        { get; set; }
  
        public string Name
        { get; set; }
  
        public string Value
        { get; set; }
  
        public int Units
        { get; set; }
    }
}

If you have any questions, please let me know
Thanks
Richard
Tags
GridView
Asked by
Tim
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Share this question
or