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

4 posts, 0 answers
  1. A.p.kumar
    A.p.kumar avatar
    8 posts
    Member since:
    Oct 2015

    Posted 27 Oct 2015 Link to this post

    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 ............
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    277 posts

    Posted 28 Oct 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jim
    Jim avatar
    1 posts
    Member since:
    Jun 2016

    Posted 02 Nov Link to this post

    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

  5. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    135 posts

    Posted 02 Nov Link to this post

    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!
Back to Top