Where is HitTestInfo?

  • Thread starter Thread starter Brett Romero
  • Start date Start date
Brett,

HitTestInfo declaration is nested in the DataGrid.

In MSDN's Index type DataGrid.HitTestInfo class in order to find the docs.

If you want to create variable of this type you should declare it as

DataGrid.HitTestInfo hitTestInfo;
 
Perhaps you didn't read my original post. You can clearly see I have
referenced DataGrid above and no HitTestInfo. Are you saying I need to
download something from MSDN?

Thanks,
Brett
 
Brett,

In this case I still don't understand the question.

You said:
I've read on the forums of other people having problems with
HitTestInfo not appearing.
System.Windows.Forms.DataGrid doesn't have it either. Any ideas?

I thought the problem is that HitTestInfo is not there (or Intellisense
doesn't show it) and DataGrid class doesn't have it. Even more - the
subject of the question is "Where is HitTestInfo?"

I think I correctly understood that the problem is the HitTestInfo class.

Are you saying that you cannot find the DataGrid class? Make sure that you
reference System.Windows.Forms.dll.

Maybe you should rephrase the question. Give more background of the problem
you are experiencing. With such a vague question I don't think anyone on the
ng can give you an answer.
 
I'm not sure how much simpler I can make it. I type
System.Windows.Forms.DataGrid. and look through the intellisense
listing. No HitTestInfo. What part of this is confusing? I do have a
DataGrid on my form. System.Windows.Forms. does show DataGrid in
intellisense. I scroll to DataGrid, hit the <enter> key and now I have
System.Windows.Forms.DataGrid. I type a dot and now I have
System.Windows.Forms.DataGrid. (notice the dot after DataGrid, which is
not a period) and intellisense waiting for me to choose something.
HitTestInfo is not a choice for me here because it "isn't" listed. It
doesn't display in intellisense.

I seems you understood the question initially very well:
I thought the problem is that HitTestInfo is not there (or Intellisense
doesn't show it) and DataGrid class doesn't have it.

That is right. DataGrid class didn't have it.

Sorry, just not sure how much clearer I can get. If it is still
confusing, perhaps I'll just wait to see who posts or I'm just out. No
need for us to keep examing how many shades of red an apple has.

Thanks,
Brett
 
On my work machine, I created a test project and HitTestInfo is there.
I checked my original solution that has two project. No HitTestInfo
for projectB. However, it is accessible from projectA. I opened
projectB outside of the solution and HitTestInfo is there. It seems
that when HitTestInfo is in the solution with projectB, HitTestInfo is
not accessible. Any ideas why?

Thanks,
Brett
 
Here's the problem. The class I'm in inherits
System.Windows.Forms.Form as it is a form. That means I'm one
namespace to far up. Any suggestions on how I get around this are
welcome.
 
Hey, I was trying to help. If I were asking question I'd give as much info
as it possible to make it easier for the people to answer it.

Anyways...
I was able to repro the problem. It just happened that I tried the
Intellisense on DataGrid inside the project I was working on - no
HitTestInfo nor any other nested type (DataGrid declares couple more). In
the test project that I created when I read your post first it was working.
All the references were OK. It is definitely bug in Intellisens.

Knowing that VS keeps some Intellisense information in the *.projdata file
(in the project's *obj* folder) I closed VS and deleted that file. I did
this for the project where Intellisense didn't work.

When I opened the project again it was working.

So, go ahead and try to delete the *projdata file.

If it doesn't help you gonna need to type all the members by hend. Even the
Intellisense doesn't work the project has to compile as long as there is no
errors
 
Sorry, didn't mean to offend. Guess I didn't understand the problem
enough and was posting gibberish. Not trying to claim I know more than
you. I appreciate all of your help greatly.

I did also get it to work by just typing HitTestInfo. All of the weird
compile errors went away. Not sure why. I also had to manually type
hit.Row or hit.Column. No intellisense. It is all working now.

I didn't find a *.projdata file. I'm using VSS with VS.NET so not sure
if that changes things. I do have these files:
*.csproj
*.scc
*.sln
*.csproj.user
*.suo
*.csproj.vspscc

That tip on deleting the file and getting intellisense back would be
great. Any idea why our setups are different in reference to
*.projdata?

Here's the code that will get the coordinates of a cell in a datagrid.
Also highlights the clicked row and dehighlights when a new row is
clicked. One thing, how do I get the value in say column 2 when all I
have are coordinates? I can't use CurrentCell or EditCell. I'm using
the right mouse click so there is no EditCell. CurrentCell gives a
cell from left clicking. I just need something I can feed in my row
index, traverse to a column and get that value.

private int lastRowSelected = 0;


private void Participant_MouseDown(object sender, MouseEventArgs e)
{
//Participant is the datagrid name
Participant.UnSelect(lastRowSelected);

Point pt = new Point(e.X, e.Y);
System.Windows.Forms.DataGrid.HitTestInfo hit =
Participant.HitTest(pt);
if (e.Button == MouseButtons.Right)
{
if(hit.Type == DataGrid.HitTestType.Cell)
{
Participant.Select(hit.Row);
lastRowSelected = hit.Row;
}
}
}

Thanks agian,
Brett
 
Brett,

When you open project in VSS it should create two subfolders - 'bin' and
'obj'. Both folders have subfolders in their own - Debug and Release.

Look at
[project folder]\obj\Debug
and
[project folder]obj\Release

there have to be files with extension 'projdata', delete them

Or, easier, delete the whole 'obj' folder all together; VS will create it
again
 
Ok, I tried that but HitTestInfo still doesn't show up. Deleted both
the bin and obj folders then rebuilt.

Any ideas on getting a datagrid cell value using coordinates?

Thanks,
Brett
 
Other than HitTest method? ...Hm I can't think of anything. DataGrid.HitTest
is meant to be used for this.

Sorry to hear deleting those files/folders didn't work for you, they
certainly did work for me.
 
Here's a revised "if" statement that does get the cell value:

if(hit.Type == DataGrid.HitTestType.Cell)
{
Participant.Select(hit.Row);
DataGridCell dgc = Participant.CurrentCell;
dgc.RowNumber = hit.Row;
dgc.ColumnNumber = 2;
Participant.CurrentCell = dgc;
personIDToFile = Participant[dgc].ToString();
//save current cell for dehighlighting on next selection
lastRowSelected = hit.Row;
}

Another question on this, how do I handle some one highlighting a cell,
holding down shift and selecting three rows. I'd like to get the value
from column three for each of those rows (as I do above). My current
method will always get the value from the cell where the right mouse
click occurred. Any ideas?

Thanks,
Brett
 
Back
Top