Can not select current row in datagrid
-
21 iulie 2012 13:48
hello Why cant I select current row in datagrid...
what I want is when grid is showing orders list and any cell is selected from this grid and I click show detail
It shall change grid view to show new table according to one value in 2nd cell (orderID column )of this selected row
Is there some property which is disabling it.. I cant see any intellisense options for Rows!!!! btw i populated this view by using
I am using WPF and c# .net on VS2010
moreover when i select datagrid.currentcell I dont get back the value in string format how to do that??
dataGrid.DataContext = tableName; dataGrid.ItemsSource = dsOrderInfo.Tables[tableName].DefaultView;
code which is not working is:
private void btOpenOrder_Click(object sender, RoutedEventArgs e) { if (dataGridShowOrders==true) { dataGrid.currentRow } }
Toate mesajele
-
21 iulie 2012 16:45
To select the current row you can try with:
dataGrid.CurrentRow.Selected = true;
Mitja
-
21 iulie 2012 17:44Thanks for your wonderfull reply this works for everyone.. but not for me... as there is no property called currentRow in my VS... lols!!! may be I have set someother property which have disabled it.. I have even tried to see class DATAGRID... (using F12 on some function call to that class.... )I cant find any such property!!!!!
-
30 iulie 2012 07:12Moderator
Hi csdeol,
It is true there is no CurrentRow property in DataGrid class.
However, you can get the current row index by:
dataGrid.CurrentRowIndex;
or
dataGrid.CurrentCell.RowNumber;
In Windows Forms, you can also use DataGridView class, there is CurrentRow property.
If you are using WPF, I suggest you to post in Windows Presentation Foundation (WPF) forum for help.
Best regards,
Chester Hong
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marcat ca răspuns de Chester HongMicrosoft Contingent Staff, Moderator 10 august 2012 06:00