[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Selecting rows in a Datagrid

Posted on 2004-09-17
4
Medium Priority
?
217 Views
Last Modified: 2010-04-23
I'm using a Datagrid with a column to select the row. How do I detect that the row was selected? How do I get the data from the columns in the selected row?
0
Comment
Question by:Rick4848
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 27

Accepted Solution

by:
planocz earned 252 total points
ID: 12086230
0
 
LVL 8

Assisted Solution

by:bramsquad
bramsquad earned 248 total points
ID: 12104807
the question above is if you choose to select the whole row instead of a cell....suppose id know, i answered it :)

you need to use the CurrentCellChanged event handler to see if a new row was selected

    Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
        'do stuff here, and heres how you tell what row and column you have selected
        Dim row As Integer = DataGrid1.CurrentCell.RowNumber
        Dim col As Integer = DataGrid1.CurrentCell.ColumnNumber
    End Sub

if you want data from your datagrid, heres how you go about it (i use this in my double click event procedure)

    Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick
        'use this for err handling
        If DataGrid1.CurrentCell.RowNumber = 0 And DataGrid1.CurrentCell.ColumnNumber = 0 Then
            Exit Sub
        Else
            Me.cbosearch.SelectedIndex = DataGrid1.CurrentCell.ColumnNumber
            Me.txtSearch.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, DataGrid1.CurrentCell.ColumnNumber)
        End If
    End Sub

this line

Me.txtSearch.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, DataGrid1.CurrentCell.ColumnNumber)

should answer your second question.  you need to use the CurrentCell property with both of your problems.

~b
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question