Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Can anyone help me understand this please. I am currently using a listview control created by Glacial Components (very good control). The problem is that I don't understand an answer to a problem I was given by them why something would not work. And as it seems like a more general vb.net question I'd thought i'd try here.

 

Below is my posts and there reply:

 

Question:

 

I have tried the following but it seems to be giving an error and I can't see why??

 

Dim ptx As Integer

Dim pty As Integer

ptx = Me.lstDispDates.MousePosition.X

pty = Me.lstDispDates.MousePosition.Y

Me.lstDispDates.InterpretCoords(ptx, pty).Item.Text = ""

 

Answer:

 

what error is it giving you? I suspect the error your getting is that Item is NULL. This will happen if you double click in an area where no item exists.

 

Also remember when debugging if you try and step through that code after you've double clicked, the mouse coordinates won't be right as they will read the mouse at the moment you step over the Mouse.X and Y.

 

This is the bit I don't understand. I am running vb.net in normal debug mode

 

Also remember when debugging if you try and step through that code after you've double clicked, the mouse coordinates won't be right as they will read the mouse at the moment you step over the Mouse.X and Y.

 

Thanks

 

simon

Posted

If you debug a program, you are stepping through the code. The person was telling you that if you are debugging the section of code that sets ptx and pty to the mouse coordinates, the mouseposition will return the coordinates you are currently at while you are debugging, not when you clicked on the listview before you went into debug mode. Therefore, the position will be incorrect, there will be no item in that area, and the Item object will be set to null.

 

Checking to see if an item actually exists where the user clicked will solve the problem.

Posted

Diesel,

 

I am new to vb.net and I have googled to try and find and example of how to check if a item exists but with no joy, is there any chance you could help me out with the code??

 

Also with regards to what you said about the debugging stepping through and giving the wrong position of the cursor, how do I get this to work properly?? Do I have to switch of debug?

 

Thanks for your help

 

Simon

  • Leaders
Posted

That means in order for ptx and pty to have a meaningful value in them, you have to let

ptx = Me.lstDispDates.MousePosition.X

pty = Me.lstDispDates.MousePosition.Y

execute regularly,

so the breakpoint should be placed on the line after it.

There, you can view the values of ptx and pty to see if they look correct. :)

 

I don't know how InterpretCoords is supposed to be used, but you may have to convert the coordinate to Client coordinates (or not).

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...