A Question concerning draging into ListViews 
Author Message
 A Question concerning draging into ListViews

Hello-

I've got a form that has a label and a ListView.  I want to be able to drag
the label onto the list view, and have it set the ListItem that it is over
to the value of the label.  I've got that part done and it works fine, but
if I drag it over a part of the list view that does not have a ListItem I
get an error.  What kind of condition can I put to check to see if it will
hit a ListItem?

Thanks.
-Steve



Mon, 08 Sep 2003 07:49:44 GMT  
 A Question concerning draging into ListViews
Have a look at these:

'** This will update the ListItem text (with the label caption)
Private Sub ListView1_DragDrop(Source As Control, x As Single, y As Single)
    Dim liHit As ListItem

    If TypeOf Source Is Label Then
        Set liHit = ListView1.HitTest(x, y)

        If Not liHit Is Nothing Then
            liHit.Text = Source.Caption
        End If
    End If
End Sub

'** This will highlight the drop target (assumes Single Selection)
Private Sub ListView1_DragOver(Source As Control, x As Single, y As Single,
State As Integer)
    Dim liHit As ListItem

    Set liHit = ListView1.HitTest(x, y)

    If Not liHit Is Nothing Then
        If Not liHit.Selected Then
            liHit.Selected = True
            ListView1.Refresh
        End If
    End If
End Sub

--
Good Luck,

Joe

Quote:
> Hello-

> I've got a form that has a label and a ListView.  I want to be able to
drag
> the label onto the list view, and have it set the ListItem that it is over
> to the value of the label.  I've got that part done and it works fine, but
> if I drag it over a part of the list view that does not have a ListItem I
> get an error.  What kind of condition can I put to check to see if it will
> hit a ListItem?

> Thanks.
> -Steve



Mon, 08 Sep 2003 09:27:55 GMT  
 A Question concerning draging into ListViews
Thanks for the help.

It worked great.

-Steve


Quote:
> Have a look at these:

> '** This will update the ListItem text (with the label caption)
> Private Sub ListView1_DragDrop(Source As Control, x As Single, y As
Single)
>     Dim liHit As ListItem

>     If TypeOf Source Is Label Then
>         Set liHit = ListView1.HitTest(x, y)

>         If Not liHit Is Nothing Then
>             liHit.Text = Source.Caption
>         End If
>     End If
> End Sub

> '** This will highlight the drop target (assumes Single Selection)
> Private Sub ListView1_DragOver(Source As Control, x As Single, y As
Single,
> State As Integer)
>     Dim liHit As ListItem

>     Set liHit = ListView1.HitTest(x, y)

>     If Not liHit Is Nothing Then
>         If Not liHit.Selected Then
>             liHit.Selected = True
>             ListView1.Refresh
>         End If
>     End If
> End Sub

> --
> Good Luck,

> Joe


> > Hello-

> > I've got a form that has a label and a ListView.  I want to be able to
> drag
> > the label onto the list view, and have it set the ListItem that it is
over
> > to the value of the label.  I've got that part done and it works fine,
but
> > if I drag it over a part of the list view that does not have a ListItem
I
> > get an error.  What kind of condition can I put to check to see if it
will
> > hit a ListItem?

> > Thanks.
> > -Steve



Wed, 10 Sep 2003 07:29:27 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Draging ListView Items

2. Dozy question concerning arrays

3. newbie question concerning if-then-else

4. DAO Question Concerning a Word Mail Merge from Access

5. ProjectResourceAdd concern/question

6. API Question Concerning Shell/Exec VB5.0

7. another question concerning data objects and combo boxes

8. another question concerning data objects and combo boxes

9. MTS; question concerning

10. MTS;questions concerning

11. Transaction Server; question concerning

12. Resultset Communication; questions concerning

 

 
Powered by phpBB® Forum Software