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

How to get the selected Row Data in radgridview in vb.net v.net

3 Answers 499 Views
GridView
This is a migrated thread and some comments may be shown as answers.
A.p.kumar
Top achievements
Rank 1
A.p.kumar asked on 27 Oct 2015, 08:11 AM

i have table like

 Id     Name      Age       Sex       Address

 1        xxx         23          m           yyyyyyyy

2        eee         24          f          zzzzzzzzzz

So i want the name When i select the row ,  so please tell me ............

3 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 28 Oct 2015, 09:36 AM
Hello,

In order to get the value of the selected row, you can use the SelectedItem property of the RadGridView. You  can find more information regarding it at the following documentation page - Basic Selection - Selected Items.

So in your case, the code that you can apply is something similar to the following example:

var name = ((Person)radGridView.SelectedItem).Name; //c#

Dim name = DirectCast(radGridView.SelectedItem, Person).Name //VB.Net

The example assumes that the objects bound to the RadGridView are of type Person, so you can make the necessary changes at your end.

Regards,
Stefan Nenchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Jim
Top achievements
Rank 1
answered on 02 Nov 2016, 07:36 PM

My apologies, but I'm a bit new to this forum and trying to figure out how to post a question. That being said, is there a way to search all view-able rows in a wpf radgridview? my task is to look through a gridview to see if there's a specific cell in a specific row.

 

Any help is most appreciated.

 

Regards,

 

Jim

0
Lance | Manager Technical Support
Telerik team
answered on 02 Nov 2016, 08:55 PM
Hello Jim,

I can help you find the best place to get support for UI for WPF. Can you please answer a quick question for us, so that we can provide you with the proper support? You may also be entitled to full support instead of forum posts.

I do not see any downloads from your account for UI for WPF. Telerik licensing, including trials, is per-developer. Do you have another Telerik account that you used to download the product trial, or have an account that has a license for UI for WPF? If you do not, the person whom purchased the product can assign you as a Licensed User.

Assigning you as the licensed user is free, only takes about 30 seconds and they can change the licened user at any time. The license owner only needs to use your email address in the Manage Licensed User's portal here.

Becoming the Licensed User would give you full access to Telerik Support with guaranteed response times directly from the specific product's support engineers.

Okay, onto your question.

The RadGridView has an Items property. You can iterate over that collection and check each item as you would a single selected row.

Here is an example of iterating over the GridView rows (I've also attached a screenshot and the demo). Notice that I show two approaches, one to just get the rendered rows (the GridView uses UI Virtualization) and the other to get access to all the rows.

// this is to get the currently rendered rows
var rows = this.myGridView.ChildrenOfType<GridViewRow>();
 
// myGridView.Items will get you all the data items
foreach (var item in myGridView.Items)
{
    var book = item as Book;
 
    // now you can check the DataItem for a particular value
    if (book?.Price < 10)
    {
        Debug.WriteLine($"{book.Title} is less than 10 dollars");
    }
}
 
// To confirm the counts
OutputTextBlock.Text = $"RadGridView has rendered {rows.Count()} items out of {myGridView.Items.ItemCount}";

Lastly, I do not see if you were looking for a C# or VB answer, but our documentation has both for code snippets (here's an example). If you do find something that is C#, like my example, you can quickly convert it using our online Code Converter.

If you have any further questions for the Telerik Support engineering team, you can open a support ticket here as I mentioned above.

Thank you for contacting support and for choosing Telerik by Progress.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Tags
GridView
Asked by
A.p.kumar
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Jim
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or