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

GridViewComboBoxColumn: Missing data fields: DataSource, DisplayMember, ValueMember

6 Answers 192 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sandi Markon
Top achievements
Rank 1
Sandi Markon asked on 27 Dec 2010, 09:09 AM
Following data fields are missing in GridViewComboBoxColumn properties: DataSource, DisplayMember, ValueMember.
Also GridViewComboBoxColumn doesn't function when I set these values programmatically in Designer.cs.

6 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 28 Dec 2010, 08:03 PM
Hello Sandi,

These properties are members of the GridViewComboBoxColumn in the latest version of the controls. Please take a look at this documentation which should help.
If you need further assistance, please let me know.
Richard
0
Stefan
Telerik team
answered on 29 Dec 2010, 05:54 PM
Hello Sandi Markon,

Thank you for writing.

Yes, I confirm that you cannot set these properties when using the Property Builder. However, they are still available when navigating the RadGridView smart tag or when using the Visual Studio property grid. In addition, you can change them with code.

I hope this helps.

Kind regards,
Stefan
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
0
subbarayan
Top achievements
Rank 1
answered on 15 Apr 2011, 07:10 AM
hi,

   In my GridViewComboBoxColumn have displaymember = "Name", valuemember="Id"
   My problem is, i want to store the displaymember's text (Name) to the db.  but is shows only the value member (id). How to get?
help me.

0
Richard Slade
Top achievements
Rank 2
answered on 15 Apr 2011, 09:03 AM
Hello,

In this cae you could make the ValueMember the "Name" also. If I have misunderstood your query please let me know.
Regards,
Richard
0
subbarayan
Top achievements
Rank 1
answered on 15 Apr 2011, 09:23 AM
hi ,

     Thanks your immediate reply. I did already the same. but my requirement both valueMember(id), Displaymember (Name). what to do?
0
Richard Slade
Top achievements
Rank 2
answered on 15 Apr 2011, 09:58 AM
Hello,

Here is an example for you of binding to a GridViewMultiComboColumn and then getting the changed text.

Form1 Designer File
namespace RadControlsWinFormsApp1
{
    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(284, 262);
            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(284, 262);
            this.Controls.Add(this.radGridView1);
            this.Name = "Form1";
            this.Text = "Form1";
            ((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 RadControlsWinFormsApp1
{
    public partial class Form1 : Form
    {
        private BindingList<Person> people = new BindingList<Person>();
        private BindingList<MyObject> myObjects = new BindingList<MyObject>();
  
        public Form1()
        {
            InitializeComponent();
  
            myObjects.Add(new MyObject(1, "My Object 1"));
            myObjects.Add(new MyObject(2, "My Object 2"));
            myObjects.Add(new MyObject(3, "My Object 3"));
  
            people.Add(new Person(1, "Richard", 1));
            people.Add(new Person(2, "Chris", 2));
            people.Add(new Person(3, "Peter", 3));
  
            this.radGridView1.AutoGenerateColumns = false;
  
            GridViewDecimalColumn idColumn = new GridViewDecimalColumn();
            idColumn.Name = "IdColumn";
            idColumn.HeaderText = "Id";
            idColumn.FieldName = "Id";
  
            GridViewTextBoxColumn nameColumn = new GridViewTextBoxColumn();
            nameColumn.Name = "nameColumn";
            nameColumn.HeaderText = "Name";
            nameColumn.FieldName = "Name";
  
            GridViewMultiComboBoxColumn multiColumn = new GridViewMultiComboBoxColumn();
            multiColumn.Name = "multiColumn";
            multiColumn.HeaderText = "My Object";
            multiColumn.FieldName = "MyObjectId";
            multiColumn.DataSource = myObjects;
            multiColumn.DisplayMember = "MyObjectName";
            multiColumn.ValueMember = "Id";
  
            this.radGridView1.Columns.Add(idColumn);
            this.radGridView1.Columns.Add(nameColumn);
            this.radGridView1.Columns.Add(multiColumn);
  
            this.radGridView1.DataSource = people;
            this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            foreach (GridViewDataColumn column in this.radGridView1.Columns)
            { column.BestFit(); }
  
            this.radGridView1.RowsChanged += new GridViewCollectionChangedEventHandler(radGridView1_RowsChanged);
        }
  
        void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
        {
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanged && this.radGridView1.CurrentCell.ColumnInfo.Name == "multiColumn")
            {
                MessageBox.Show("New Text is: " + this.radGridView1.CurrentCell.Text);
            }
        }
    }
  
    class Person
    {
        public Person()
        { }
  
        public Person(int id, string name, int myObjectId)
        {
            this.Id = id;
            this.Name = name;
            this.MyObjectId = myObjectId;
        }
  
        public int Id { get; set; }
        public string Name { get; set; }
        public int MyObjectId { get; set; }
    }
  
    class MyObject
    {
        public MyObject()
        { }
  
        public MyObject(int id, string myObjectName)
        {
            this.Id = id;
            this.MyObjectName = myObjectName;
        }
  
        public int Id { get; set; }
        public string MyObjectName { get; set; }
    }
}

Hope that helps
Richard
Tags
GridView
Asked by
Sandi Markon
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Stefan
Telerik team
subbarayan
Top achievements
Rank 1
Share this question
or