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

[Solved] RadGridView with auto increment column, autocomplete, databiding from cell

1 Answer 594 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Yu Chi
Top achievements
Rank 1
Yu Chi asked on 13 Dec 2009, 01:48 PM
I'm very happy when i using Telerik Controls for Winform Q2sp1 !

But i looking for some function as auto increment colum in radgridview !

How to using GridViewComboBoxColumn autocomplete function as RadCombobox ?

Some events not fired when i selecting value from GridViewComboBoxColumn, data not binding to other cell !

 

1 Answer, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 14 Dec 2009, 08:59 AM
Hello Yu Chi,

We do not have that kind of a column, because everything depends on the binding source of the grid.
You can create a DataTable in the memory with an auto-increment column. Please see the following example:

DataTable dtCbSource = new DataTable("dummytable");
DataColumn dcID = new DataColumn("ID", typeof(int));
dcID.AutoIncrement = true;
dtCbSource.Columns.Add(dcID);
dtCbSource.Columns.Add("Name", typeof(string));
 
dtCbSource.Rows.Add("Item 1");
dtCbSource.Rows.Add("Item 2");

To use GridViewComboxBoxColumn auto-complete feature you should use the following lines of code:

public GridForm()
{
    InitializeComponent();
    this.Load += new EventHandler(GridForm_Load);
    this.radGridView1.ValueChanged += new EventHandler(radGridView1_ValueChanged);
}
 
private void radGridView1_ValueChanged(object sender, EventArgs e)
{
    // Handles value change
    // sender is the editor
}
 
private void GridForm_Load(object sender, EventArgs e)
{
 
    DataTable dtCbSource = new DataTable("CbSource");
    dtCbSource.Columns.Add("ID", typeof(int));
    dtCbSource.Columns.Add("Name", typeof(string));
 
    dtCbSource.Rows.Add(1, "Item 1");
    dtCbSource.Rows.Add(2, "Item 2");
 
    GridViewComboBoxColumn cbColumn = new GridViewComboBoxColumn("comboBox", "Select");
    cbColumn.DropDownStyle = RadDropDownStyle.DropDown;
    cbColumn.DataSource = dtCbSource;
    cbColumn.ValueMember = "ID";
    cbColumn.DisplayMember = "Name";
    cbColumn.AutoCompleteMode = AutoCompleteMode.Suggest; // AutoCompleteMode.SuggestAppend;
    this.radGridView1.Columns.Add(cbColumn);
 
    DataTable dtSource = DataTableDumper.GenerateEmployees(100);
    this.radGridView1.DataSource = dtSource;
 
}

Could you provide more information regarding your problems with GridViewComboBoxColumn? It would be useful if you send a sample project that demonstrates your scenario?

Sincerely yours,

Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Yu Chi
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or