Skip to main content

Microsoft Silverlight

Answered Question How can i know the exact location of cell(which column and which row) selected in datagrid?RSS Feed

(0)

spiderman110
spiderma...

Member

Member

225 points

282 Posts

How can i know the exact location of cell(which column and which row) selected in datagrid?

 Hi, all

I have a datagrid and a textbox, when i select one cell in datagrid, the cell of message(Row[?] Column[?]) will be displayed in textbox .

How can I get the row and col message in datagrid?

 

Thanks....

ken tucker
ken tucker

All-Star

All-Star

16234 points

2,473 Posts

Answered Question

Re: How can i know the exact location of cell(which column and which row) selected in datagrid?

Try something like this. 

    Private Sub dgCategories_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgCategories.CurrentCellChanged
        txtHere.Text = String.Format("Row {0}, Col {1}", dgCategories.SelectedIndex, dgCategories.CurrentColumn.DisplayIndex)
    End Sub

    Private Sub dgCategories_SelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles dgCategories.SelectionChanged
        txtHere.Text = String.Format("Row {0}, Col {1}", dgCategories.SelectedIndex, dgCategories.CurrentColumn.DisplayIndex)
    End Sub
 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities