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

Row Selection

20 Answers 1442 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mitch Thraves
Top achievements
Rank 2
Mitch Thraves asked on 29 Apr 2007, 10:46 PM
Hi

I need to know the best way to call a client detail form by clicking on a row in a RadGridView. I'm not sure what code to put in the Click event.

My RadGridView shows 15 columns of Client data and stores the Client ID column in the first column of the Grid. I want to click on a row and then call a detail form and pass it the selected Client's ID.

I'm using VB.Net.

Many thanks

20 Answers, 1 is accepted

Sort by
0
Kiril
Telerik team
answered on 02 May 2007, 01:34 PM
Hi Mitch,

Unfortunately, the RadGridView does not currently provide a row click event which would allow you to implement this functionality. It will be provided in Service Pack 1.

Kind regards,
Kiril
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Karthik
Top achievements
Rank 1
answered on 04 May 2007, 12:40 AM
When is the service pack expected?
0
Dimitar Kapitanov
Telerik team
answered on 04 May 2007, 07:43 AM
Hello Mitch Thraves,
You should expect the SP1 release around the mid May (probably around the 15th of May).

Kind regards,
Dimitar Kapitanov
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
PortVista
Top achievements
Rank 2
answered on 07 May 2007, 07:24 PM
I've found the row or cell click event not really working as far as the MS datagrid goes. It seems to not work when you are hovering over the column size areas. So, I use DoubleClick event and then capture the row that is selected. Are you saying we can't get the selected row with DoubleClick??
0
Kiril
Telerik team
answered on 08 May 2007, 11:11 AM
Hello Jason,

The functionality that is already implemented in the upcoming Serice Pack 1 is the following:

  • A RowSelected event is fired whenever the current row changes because of a mouse click or keyboard navigation. It makes available the row that was selected.
  • A CellClicked event is fired whenever a cell is clicked. This event allows one to obtain the cell (and respectively, the row) clicked.
  • A CellDoubleClicked event is fired whenever a cell is double clicked if that cell is readonly (in case it can be edited, the respective editor is shown after the first mouse click inside the cell area). This event also allows one to obtain the cell (and respectively, the row) clicked.
In case the above functionality is not sufficient, please give me more information on what you are looking for.

Best wishes,
Kiril
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
PortVista
Top achievements
Rank 2
answered on 08 May 2007, 01:21 PM
It's hard to know without testing, but it sounds like you're doing what the MS datagrid/view does. The problem with the MS one is that if you have resizable columns, or editable cells, the row or cell click event does not fire, in favor of the column resize or cell edit events.

You need row double click event too. But again I've just found just capturing the datagrid's double click event to be sufficient. You simply check if there's a row selected. However, if you double click on the header it still fires I believe...  it's not perfect.

So if you can make the double-click event fire overriding any other event, that would seem to be what we all need. And in some cases, single click, although that wouldn't work with a editable grid...
0
Kiril
Telerik team
answered on 08 May 2007, 04:58 PM
Hello Jason,

Thank you for your feedback.

We are indeed planning to add a RowDoubleClick event in the upcoming Service Pack 1. It will fire on all rows, and you'll be able also to access the row  type.

Sincerely yours,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
xeon
Top achievements
Rank 1
answered on 09 May 2007, 09:47 AM
Hi,

This means that is no way to get the selected row?
In that case this is a pretty useless control.

Thanks
Xeon
0
Kiril
Telerik team
answered on 09 May 2007, 12:18 PM
Hi Laszlo,

In all the events described so far:

  • RowSelected
  • RowDoubleClicked
  • CellSelected
  • CellDoubleClicked
you will be able to access the selected row, together with the row type. Sorry I didn't state that explicitly in the previous messages.

Kind regards,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
PortVista
Top achievements
Rank 2
answered on 10 May 2007, 04:05 PM
Ok how do I get the selected row now? CurrentRow isn't available...

MS DataGrid
dgList.CurrentRow.Cells.Item("ContactID").Value

0
Kiril
Telerik team
answered on 15 May 2007, 10:34 AM
Hello Jason,

Thank you for bringing up this issue. We need to better document the use of current row, as well as the events that are fired when it changes.

Onto your question - a straightforward way to get the current row is to use the CurrentRow property of the GridViewInfo. Here's a short code snippet illustrating this:

GridViewRowInfo currentRow = radGridView1.MasterGridViewInfo.CurrentRow; 

 
All the best,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
xeon
Top achievements
Rank 1
answered on 15 May 2007, 12:33 PM
Hi,

Maybe this is trivial for everyone, but i added a snipet for selecting value.

GridViewRowInfo currentRow = radGridView1.MasterGridViewInfo.CurrentRow;

GridViewDataRowInfo current = currentRow as GridViewDataRowInfo;
DataRowView drow = current.DataRowView;
MessageBox.Show(drow["Name"].ToString());
0
PortVista
Top achievements
Rank 2
answered on 15 May 2007, 02:40 PM
That's insane to create that many references to get the cell value... I'll try one more time here. I'm using VB by the way.
0
Jack
Telerik team
answered on 15 May 2007, 04:19 PM
Hello Jason,

Again we must apologize for the badly documented and incomplete API.

In the Q1 SP1 we use:

string name = radGridView1.MasterGridViewInfo.CurrentRow.Cells["Name"].Value; 

and you will be able to use the following code:
 
string name = radGridView1.MasterGridViewInfo.CurrentRow.DataRowView.Row["Name"].ToString(); 

The Service Pack will probably be live tomorrow as we are still testing it. We will post an announcement in the Announcements forum as soon as we are ready with the release.
 

Greetings,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
PortVista
Top achievements
Rank 2
answered on 15 May 2007, 06:19 PM
Well this is the most confusing thread ever. Might as well just delete it.
0
Jack
Telerik team
answered on 17 May 2007, 12:13 PM
Hello Jason,

I apologize for this misunderstanding. My last post was really confusing. What I meant to say is that in our current version (Q1 SP1) you can access the Cell value by using the Cells property of any Row (e.g):

string name = radGridView1.MasterGridViewInfo.CurrentRow.Cells["Name"].Value;

In our previous version (Q1) you can achieve the same with this code:

string name = radGridView1.MasterGridViewInfo.CurrentRow.DataRowView.Row["Name"].ToString();

 
Regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
carisch
Top achievements
Rank 1
answered on 25 Jul 2007, 09:22 PM
How do i know what service pack (or version) i'm on?  I downloaded the trial on July 24th.
0
Jack
Telerik team
answered on 26 Jul 2007, 10:06 AM
Hi Brian,

You can check RadControls version in several ways:

  1. Open Visual Style Builder and choose Help -> About from the main menu.
  2. In Windows Explorer, locate and open the "RadControls for WinForms Folder" (usually C:\Program Files\Telerik\RadControls for WinForms Q1 2007\). Navigate to the bin folder, select the Telerik.WinControls.dll (or any of the dll file from the list, except RadChart), right click on it and select Properties -> Version.
  3. A nice Windows feature is that you can show the versions at all times. This is done by adding the File Version column to the explorer view. Here are the steps:
    1. In Windows Explorer, locate and open the "RadControls for WinForms Folder" (usually C:\Program Files\Telerik\RadControls for WinForms Q1 2007\).
    2. Navigate to the bin folder.
    3. Right-click on any column header in the view, and select More...
    4. Locate File Version and check the checkbox.
    5. Click OK. The file versions will appear in the view.
    6. To save the new view layout, go to the Tools menu --> Folder Options --> View tab --> Apply to all folders --> OK.
You can check the version number against the release version here: Release History.

 
Kind regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Christian
Top achievements
Rank 1
answered on 23 Sep 2008, 02:28 PM
Hi,
I use the version 7.1.1.0 and cannot find the event RowDoubleClicked. For a reference I would be grateful.

Christian
0
Nikolay
Telerik team
answered on 24 Sep 2008, 10:28 PM
Hello Christian,

We decided not to implement the RowDoubleClicked event for the time being, because the CellDoubleClicked event is sufficient to obtain the double clicked cell and its respective row. For example if you want to get the row and do some modifications to it, here is how this could be done:
 
void radGridView1_CellDoubleClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)  
{  
    Console.WriteLine(e.RowIndex);  
    if (e.RowIndex > 0)  
    {  
        GridViewRowInfo row = this.radGridView1.Rows[e.RowIndex] as GridViewRowInfo;  
        if (row != null)  
        {  
            foreach (GridViewCellInfo cell in row.Cells)  
            {  
                if (cell.ColumnInfo is GridViewDecimalColumn)  
                {  
                    cell.Value = 0;  
                }  
                else if (cell.ColumnInfo is GridViewTextBoxColumn)  
                {  
                    cell.Value = String.Empty;  
                }  
                else if (cell.ColumnInfo is GridViewDateTimeColumn)  
                {  
                    cell.Value = DateTime.Now;  
                }  
            }  
        }  
    }  

 
Please note that on a RadGridView with ReadOnly set to falseCellDoubleClick will be fired only if you double click on the GridRowHeaderCellElement. However, if you click on a normal data cell, its editor will be opened and the CellDoubleClick event will not be fired. If RadGridView.ReadOnly is set to true, the CellDoubleClick event will be fired when you double click on regular data cells as well.

If you have additional questions, feel free to contact me.
 

All the best,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Mitch Thraves
Top achievements
Rank 2
Answers by
Kiril
Telerik team
Karthik
Top achievements
Rank 1
Dimitar Kapitanov
Telerik team
PortVista
Top achievements
Rank 2
xeon
Top achievements
Rank 1
Jack
Telerik team
carisch
Top achievements
Rank 1
Christian
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or