Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi all,

Is it possible to programmatically select row from DataGird where Column ID = ID (from textbox txtIMID.text on UserControl) on UserControl load?

Thank you in advance
Posted
Comments
Maciej Los 11-Apr-14 16:51pm    
What have you tried? Where are you stuck?
LordVovin 11-Apr-14 17:27pm    
Hi,

I was trying to get the row index first, then get cell value. (for each item as DataRowView in dgMyKaizens.ItemsSource). There was no error when I was trying to get cell value to textbox.

To select row I used:

Dim cel As Integer = item.Item("ID")
' If id = cel Then
' dgMyKaizens.SelectedItem = cel
' dgMyKaizens.ScrollIntoView(item)
' End If

Without any progress on that...

1 solution

Please, read my comment to the question.

As far as i know, you can filter the the DataGrid' items through the ICollectionView which supports filtering. Have a look here: How to: Group, Sort, and Filter Data in the DataGrid Control[^]
 
Share this answer
 
Comments
LordVovin 11-Apr-14 17:42pm    
Well, I could fiter DataGrid first to get only row with regarding ID and then select it as a 0 row, but I need DataGrid with all records (management request...).

I will read this for sure. Thank you!
Maciej Los 11-Apr-14 18:01pm    
You're welcome. Let me know if it was helpful ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900