I have a grid that uses external "Add"Row" controls all works fine if the grid sort is the "Default"
however if you swith the sort and they are now descending this code won't work
:
.CreateNew();
val.QualificationID = _vm.SelectedQualificationList.QualificationID;
val.ItemValue =
;
_vm.obsValueList.Insert(
, val);
try
{
];
r.IsSelected =
grdSelectedVals.EnterEditMode(r, c);
grdSelectedVals.IsEnabled =
_vm.IsDirty =
}
ex)
ex;
it will go the the first row in the grid and relapce the exisitn value.
is there a wasy I can test the sort of the column so i know whether or not to select row ")" or the last row in the grid?
yes I am , there are only 2 columns on this grid (it's fixed)
Hi,
Out of curiosity, why are you wrapping it in a Try/Catch?
Are you doing this instead of a null ref check? B/c not all Columns are of type Column you should be wrapping the check in a null ref check.
Or, you can just grab the DataColumns:gridSelectedVals.Columns.DataColumns[1]
-SteveZ
Nope I'm all set thanks
this code is doing the trick
int insertIDX = 0
var column = this.grdSelectedVals.Columns[1] as Column;
if (column.IsSorted == SortDirection.Ascending || column.IsSorted == SortDirection
.None)
insertIDX =
0
else
insertIDX = grdSelectedVals.Rows.Count;
catch
{ }
I’m not sure if you are still having issues with identifying the sorted columns.
If you are using the xamGrid UI to sort the columns, ascending or descending wouldn’t matter, the count should indicate the number of columns that have been sorted. And you should be able to identify which columns have been sorted by getting the Key values.
Let me know if you’re still having issues with the SortedColumns.Count and if so how are you sorting the columns?
Actually I just found another post where somone is doing this and it works
have to check for "none" as well or it will throw an error.
thanks