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

Select a specific cell programmatically

9 Answers 569 Views
GridView
This is a migrated thread and some comments may be shown as answers.
OverCoded
Top achievements
Rank 2
OverCoded asked on 29 Jul 2010, 10:03 PM
I would think this would be as simple as a very short line of code,however there seems to be a substantial layer of complexity involved, or so it would seem. All I need to do is set a specific data cell into edit mode (programmatically), I have the row, and I know the column but none that is of any use. More in depth documentation would be nice. All we are given in the documentation is "this.radGridView.BeginEdit();" and all that does is set the first item in the selected row into edit mode, I don't want that cell. I want the second and third. Any ideas would be great other than those referencing deprecated code. I am using the current version of Telerik WPF.

9 Answers, 1 is accepted

Sort by
1
Milan
Telerik team
answered on 30 Jul 2010, 02:34 PM
Hi Mark Coe,

You can use the following code:

private void Button1_Click(object sender, RoutedEventArgs e)
{
    var item = this.clubsGrid.Items[3];
    var column = this.clubsGrid.Columns[1];
    var cellToEdit = new GridViewCellInfo(item, column, this.clubsGrid);
  
    this.clubsGrid.CurrentCellInfo = cellToEdit;
    this.clubsGrid.BeginEdit();
}

We appreciate your feedback and we will consider providing more information on this topic.


Best wishes,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
OverCoded
Top achievements
Rank 2
answered on 30 Jul 2010, 07:08 PM
That worked great thanks. I get the correct selected cell and it appears to be in an edit mode, however the value does not change (programmatically).
0
Milan
Telerik team
answered on 02 Aug 2010, 07:48 AM
Hi Mark Coe,

So you would like to change the value of that cell using code? If that's the case you can simply work with the data layer and change the properties of the data items instead of working with the UI.


Regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jacob Distel
Top achievements
Rank 1
answered on 08 Feb 2011, 05:52 PM

I am trying to do something similar and this example doesn't work for me. I'm trying to select a certain cell on the CellEditEnd. Is this possible?

private void gvInfo_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e)
       {
           GridViewCell tmpCell = e.Cell;
           GridViewRowItem gvri = tmpCell.ParentRow;
           DataRowView tmpRow = (DataRowView)gvri.Item;
           switch (tmpCell.Column.UniqueName)
           {
               case "UniqueName":
               {
                     //I do some data manipulation here
                     //I want to select a certain cell in the same row here and I know which column I want to select.
               }
               break;
               case "UniqueName2":
               {
                     //I do some data manipulation here
                     //I want to select a certain cell in the same row here and I know which column I want to select.
               }
               break;
                }
             }
                
0
Maya
Telerik team
answered on 09 Feb 2011, 10:21 AM
Hi Jacob Distel,

May you provide a bit more details about the exact goal you want to achieve ? Why do you want to change the current cell on the CellEditEnded event ? What is the behavior you want to get ?
Once I have more information about your scenario, I may be able to provide you with a proper solution. 
 

Greetings,
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
Jacob Distel
Top achievements
Rank 1
answered on 09 Feb 2011, 03:16 PM
Hi Maya,
I have many columns in this grid, a few of the columns are editable, but many are not. Most of the columns that are NOT editable are populated with data based off of calculations using the data in the other columns. It's like a giant spreadsheet. When the user enters data into a cell I do a calculation with that data and depending on the result, I need to send the user to a different column to enter more information. For example, if someone enters a 0 into column 1, I need to send them to column 2. But, if they enter a number between 1 - 50 into column 1, I need to send them to column 3. It's like that with most of the columns that are editable.

The reason I do it in the CellEditEnd event is because that is where I do my data manipulation (I do more than just calculations). If there is a better solution for this, I'm willing to try it.

Thanks!
0
Jacob Distel
Top achievements
Rank 1
answered on 12 Feb 2011, 01:55 PM
Any suggestions on this?
0
Maya
Telerik team
answered on 14 Feb 2011, 06:22 PM
Hi Jacob Distel,

In this case you may set the CurrentColumn instead. However, you will need to predefine the default keyboard behavior as described here
I am sending you a sample project illustrating the provided suggestion. 

 

Regards,
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
Jacob Distel
Top achievements
Rank 1
answered on 14 Feb 2011, 10:59 PM
That sample project did exactly what I was looking to do.

Thank you, Maya!
Tags
GridView
Asked by
OverCoded
Top achievements
Rank 2
Answers by
Milan
Telerik team
OverCoded
Top achievements
Rank 2
Jacob Distel
Top achievements
Rank 1
Maya
Telerik team
Share this question
or