DataGrid TapCellEventArgs args.ColumnIndex not working

I’m using the datagrid class in a project where I need to respond to a user touching a particular cell in the datagrid. I have the datagrid example from the Glide library running in the debugger and added a line of code to make sure I was getting the correct row and column indices for the cell touched in a datagrid.

The row index always works, but if you scroll the datagrid the row index is correct but the column index always comes back as zero no matter what cell you press.

A snippet of the Glide library DataGrid example is attached with the line I added to check the column index.



static void dataGrid_TapCellEvent(object sender, TapCellEventArgs args)
 {
            // Get the data from the row we tapped.
            object[] data = dataGrid.GetRowData(args.RowIndex);
            if (data != null)
                GlideUtils.Debug.Print("GetRowData[" + args.RowIndex + "] = ", data);
                GlideUtils.Debug.Print("GetColData[" + args.ColumnIndex + "] = ", data);  //the line I added to view the column index
}


Thanks in advance.

Welcome to the community!

You can add Glide project to your solution and check what is going on there and how exactly column index is assigned.

Thanks.

I’ve been searching the glide source, but I’m not sure where I should start looking to see what could be “zeroing out” the coIumn index after scrolling the datagrid. I have also been single stepping through the code in debug mode, but again I’m not sure where to put a break point to see when column index is zeroed after a scroll then touch.

Check stack and thread windows after you break into the debugger.

Codeplex has been updated with a fix for this.

GetRowData will return all columns for the RowIndex. Then you use ColumnIndex to get the column that was tapped.

using Microsoft.SPOT;

object[] data = dataGrid.GetRowData(args.RowIndex);
if (data != null)
	Debug.Print(data[args.ColumnIndex].ToString());

That was quick! ;D

It works now! That was quick.

Also just FYI for Architect. I did try the stack window but Visual Studio Express doesn’t have a thread window. It looks like its only in the full version.

Thanks.

Yep, it is one of the missing features in Express edition. You haven’t mention it so I’ve assumed you are using on the full flavors.