Click here to Skip to main content
15,888,113 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Determine what App called your vb.net dll Pin
nlarson1123-Jan-07 3:21
nlarson1123-Jan-07 3:21 
GeneralRe: Determine what App called your vb.net dll Pin
Csorba223-Jan-07 9:22
Csorba223-Jan-07 9:22 
QuestionGet Calling application from my vb.net dll Pin
Csorba222-Jan-07 10:37
Csorba222-Jan-07 10:37 
AnswerRe: Get Calling application from my vb.net dll Pin
Dave Kreskowiak22-Jan-07 10:44
mveDave Kreskowiak22-Jan-07 10:44 
QuestionDisable Right-Click selecting in ListView - VS2005 Pin
Dnkuser22-Jan-07 7:57
Dnkuser22-Jan-07 7:57 
AnswerRe: Disable Right-Click selecting in ListView - VS2005 Pin
Christian Graus22-Jan-07 9:34
protectorChristian Graus22-Jan-07 9:34 
GeneralRe: Disable Right-Click selecting in ListView - VS2005 Pin
Dnkuser23-Jan-07 1:44
Dnkuser23-Jan-07 1:44 
AnswerRe: Disable Right-Click selecting in ListView - VS2005 Pin
TwoFaced22-Jan-07 21:19
TwoFaced22-Jan-07 21:19 
I think I solved it. I created my own class that inherits the ListView class. I messed around with overriding the WndProc method. I made a few small changes and it works great as far as I can tell. If you add this class to your project you should be able to use it just like any other control. It will be added to the tools menu automatically (at least it gets added for me). Sometimes I have to run my application once before it gets added. If you have trouble getting it to work let me know. It works exactly as a ListView control except for the fact that it won't change selections if you click off of an item. If you want it to behave slightly differently then let me know and I can help you make the changes. For instance do you want the context menu to appear if a user clicks off of an item? I can stop that too. Or would you like it to not select an item at all when the context menu is displayed? I would recommend leaving that behavior because it seems standard. Well here is that class. Hope it helps.
Public Class ListView_NoRightClickChange
    Inherits ListView
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        'Right mouse button message ID
        Const WM_RBUTTONDOWN As Integer = &H204

        If m.Msg = WM_RBUTTONDOWN Then
            'Mouse position relative to me
            Dim mousePos As Point = Me.PointToClient(Me.MousePosition)

            'If item wasn't selected then change message to prevent
            'selection changes
            If Me.HitTest(mousePos).Item Is Nothing Then
                m.WParam = New IntPtr(-1)
            End If
        End If

        MyBase.WndProc(m)
    End Sub
End Class


**EDIT**
I re-read your post and I think that you would like the selection to stay the same even if a user right-clicks a non-selected item. If that's the way you'd like it then it's even less code. Here is the class that will make that happen.
Public Class ListView_NoRightClickChange
    Inherits ListView
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        'Right mouse button message ID
        Const WM_RBUTTONDOWN As Integer = &H204

        If m.Msg = WM_RBUTTONDOWN Then m.WParam = New IntPtr(-1)
        MyBase.WndProc(m)
    End Sub
End Class

GeneralRe: Disable Right-Click selecting in ListView - VS2005 Pin
Dnkuser23-Jan-07 2:21
Dnkuser23-Jan-07 2:21 
GeneralRe: Disable Right-Click selecting in ListView - VS2005 Pin
TwoFaced23-Jan-07 7:13
TwoFaced23-Jan-07 7:13 
GeneralRe: Disable Right-Click selecting in ListView - VS2005 Pin
Dnkuser23-Jan-07 7:37
Dnkuser23-Jan-07 7:37 
GeneralRe: Disable Right-Click selecting in ListView - VS2005 Pin
TwoFaced23-Jan-07 13:30
TwoFaced23-Jan-07 13:30 
QuestionPort Scanner Pin
rfrank535622-Jan-07 7:45
rfrank535622-Jan-07 7:45 
AnswerRe: Port Scanner Pin
Dave Kreskowiak22-Jan-07 10:15
mveDave Kreskowiak22-Jan-07 10:15 
QuestionMDI Form Trouble! Pin
China-Gary22-Jan-07 6:48
China-Gary22-Jan-07 6:48 
AnswerRe: MDI Form Trouble! Pin
KevinMac22-Jan-07 8:22
KevinMac22-Jan-07 8:22 
QuestionPassing a parameter to a Crystal Report via an ASP page [modified] Pin
bazpaul22-Jan-07 5:27
bazpaul22-Jan-07 5:27 
QuestionDate and time picker Pin
kendo1722-Jan-07 5:04
kendo1722-Jan-07 5:04 
AnswerRe: Date and time picker Pin
nlarson1122-Jan-07 8:28
nlarson1122-Jan-07 8:28 
QuestionCustom Control Pin
CodingYoshi22-Jan-07 3:46
CodingYoshi22-Jan-07 3:46 
AnswerRe: Custom Control Pin
Ray Cassick22-Jan-07 4:17
Ray Cassick22-Jan-07 4:17 
GeneralRe: Custom Control Pin
CodingYoshi22-Jan-07 4:52
CodingYoshi22-Jan-07 4:52 
GeneralRe: Custom Control Pin
Taylor Kobani22-Jan-07 22:52
Taylor Kobani22-Jan-07 22:52 
QuestionTimer event ? Pin
cadorna200322-Jan-07 3:03
cadorna200322-Jan-07 3:03 
AnswerRe: Timer event ? Pin
Dave Kreskowiak22-Jan-07 10:22
mveDave Kreskowiak22-Jan-07 10:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.