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

Insert data on column editing

4 Answers 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jagan k
Top achievements
Rank 1
Jagan k asked on 08 Jan 2011, 08:46 AM
hi ,

i am using RadGridView and GridViewDataColumn. i need to insert some data in to the cell while the cell is in editing mode.
for example i am having a com port which read data from the weighing machine and it has to be displayed in the cell when the user press a key (say F4) on edit mode.
i diaplying the weighing scale value in label control but not in the RadGridView.


thanks
jagan

4 Answers, 1 is accepted

Sort by
0
Jagan k
Top achievements
Rank 1
answered on 08 Jan 2011, 08:57 AM
i am adding the image for the above scenario
0
Maya
Telerik team
answered on 10 Jan 2011, 10:31 AM
Hello Jagan k,

If you want to change the value of the cell in edit mode once a particular key is pressed, you may handle the PreviewKeyDownEvent for example and make sure that the pressed key is the one you want. Afterwards you may change the value of the item using the corresponding property of that column:

this.playersGrid.PreviewKeyDown += new KeyEventHandler(playersGrid_PreviewKeyDown);
 
void playersGrid_PreviewKeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.F4)
    {              
        var currentCell = this.playersGrid.CurrentCell as GridViewCell;
        if (currentCell.IsInEditMode)
        {
            var property = currentCell.DataColumn.DataMemberBinding.Path.Path;
            var editedItem = currentCell.ParentRow.Item as Player;
            var objectType = typeof(Player);
          objectType.GetProperty(property).SetValue(editedItem, "NewValue", null);
        }
    }
}

In this case the "NewValue" is the value you want to insert in that particular cell.
 

Best wishes,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Jagan k
Top achievements
Rank 1
answered on 17 Jan 2011, 03:33 PM
hi,
thanks for  your fast response. your code works great. but i need to change the entered value before the cellendedit as occurred in the edit control itself.
suggest the ways to implement

jagan
0
Siingh
Top achievements
Rank 2
answered on 03 Jun 2011, 09:21 AM
Hi Telerik
I saw your post above i want to know what is Player you used inside? is it a datasource? like normly u all use Club.vb?

i wan to use this same approach but my gridview is binded with Datatable how od i use this approach to edit cell.


Kind Regards:
Tags
GridView
Asked by
Jagan k
Top achievements
Rank 1
Answers by
Jagan k
Top achievements
Rank 1
Maya
Telerik team
Siingh
Top achievements
Rank 2
Share this question
or