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

On Combo(GridViewComboBoxColumn) Select Effect other Cells

2 Answers 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Syed Asad
Top achievements
Rank 1
Syed Asad asked on 27 Apr 2011, 08:36 AM
This code not working 
I need to change Description cell text on combo selection of GridViewComboBoxColumn 
"gvItems" is my grid

 public void GridInitialize()
        {
            try
            {
                Database.JangDataContext DC = new Database.JangDataContext();
                gvItems.AutoGenerateColumns = false;

                // Ini Col 1
                var itemColumn = new GridViewComboBoxColumn("Items");
                itemColumn.FieldName = "Item_ID";
                itemColumn.ValueMember = "Item_ID";
                itemColumn.DisplayMember = "Item_Name";
                itemColumn.DataSource = (from Itm in DC.Items where Itm.IsActive == true select Itm).ToList();
                gvItems.Columns.Add(itemColumn);
                gvItems.Columns[0].Width = 65;


                // Add Selected Text Event
                gvItems.SelectionChanged += new EventHandler(gvItems_SelectionChanged);                
                //  End Ini Col 1

                var itemDetailColumn = new GridViewTextBoxColumn("Description");
                itemDetailColumn.FieldName = "Item_Description";
                itemDetailColumn.HeaderText = "Description";
                gvItems.Columns.Add(itemDetailColumn);
                gvItems.Columns[1].Width = 165;


                // Ini Col 2
                // End Ini Col 2
            }
            catch (Exception Ex) { MessageBox.Show("Some error occer while initialization grid : Error Code = {0}", Ex.Source); }
        }
void gvItems_SelectionChanged(object sender, EventArgs e)
        {            
            gvItems.CurrentRow.Cells["Description"] = "Hello There ";
         }

2 Answers, 1 is accepted

Sort by
0
Syed Asad
Top achievements
Rank 1
answered on 27 Apr 2011, 08:40 AM
gvItems.CurrentRow.Cells["Description"].Value = "Hello There ";

is not working to
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 29 Apr 2011, 02:06 PM
Hello Syed,

Change this:
gvItems.CurrentRow.Cells["Description"] = "Hello There ";
to this:
gvItems.CurrentRow.Cells["Item_Description"] = "Hello There ";

Because that is the field the column is bound to.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
Tags
GridView
Asked by
Syed Asad
Top achievements
Rank 1
Answers by
Syed Asad
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Share this question
or