DataGriud Row,Column to bound table Row,Column translation.

G

Guest

Using the HitTestInfo class in conjunction with HitTest I can get the row and
column on a DataGrid. Now is what I would like is to translate that row and
column to the row and column on the DataSource (in this case it is a
DataTable). Any ideas?

Kevin
 
G

Guest

This article gives me the row number but I also need the column number. Is
this also handled via the currency manager?

Thanks again.
 
G

Guest

One more question. I think this article assumes that the user has clicked on
a particular row to make it current. I am using HitTest from within MouseMove
so I don't think I can make any assumptions about the "current" postion.
HitTest seems to do the work of translating the coordinates of the mouse to
row and column numbers in the DataGrid. I just need to translate those row
and column numbers to row and column numbers of the assocated table.

Thanks again.
 
G

Guest

I spent some time working on this issue. One of the things I realized is that
if we are looking at the data then we will never get a live picture of what
is happening in the cell.

What we need to understand is where in the architecture the data is being
modified. It is in a textbox in the DataGridTextBoxColumn ( DGTBC ). To get
to the data as it is being typed in this textbox we can create a class
derived from ( DGTBC ).

I have started a blog at http://www.thorkornbrek.net

There is a slightly more detailed explanation of what I have done and sample
files.

I hope this helps.
 
G

Guest

Thank you for your post and continued interest.

I am not sure how this sample addresses the issue of translating the
DataGrid Row,Column as reported by HitTest to the bound table Row and Column.

Kevin
 
G

Guest

You are correct this article gives you the row number that is selected. The
currencymanager is bound to the datagrid. The current property of the
currency manager returns the currently selected datarow.

You can use the column information from the HitTest to retreive the data.

If you add the Global class that is in the article to your application then
use it like this.

DataRow drTarget = Global.CurrentRow(myDataGrid);
myTextBox.Text = drTarget[colFromHitTest].Value;


This will allow you to update your textbox dynamically.
 
G

Guest

It addresses the initial problem that you expressed. The need for data as it
is typed into a datagrid so that other controls can be updated.

I just added a response to this thread about using the code from the article
I pointed you to if it is more important to use the HitTest method.

Just be aware that the any method tied to the datasource will not be updated
until after the answer is committed to that datasource.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top