-
Aug 16th, 2004, 06:04 PM
#1
Listview LabelEdit on Sub Items [Resolved]
How do you set the label edit on certain sub items and restrict on
others? I toggle between automatic and manual as a way to lock
the lvw. So when I want to allow editing, I need to let the user
edit subitems also.
Thanks.
Last edited by RobDog888; Aug 17th, 2004 at 12:57 PM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Aug 16th, 2004, 06:38 PM
#2
If I can determine what sub item the click is in I guess I could
show a textbox over the listview, but how to know which
subitem?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Aug 17th, 2004, 11:10 AM
#3
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Aug 17th, 2004, 12:12 PM
#4
Here is code to determine which ListView SubItem was clicked. To run this example, just open a new project and put a ListView on the default Form. You'll also have to add a Module.
In the Form:
VB Code:
Option Explicit
Private Sub Form_Load()
Dim LI As ListItem
ListView1.View = lvwReport
ListView1.GridLines = True
ListView1.ColumnHeaders.Add , , "Col1"
ListView1.ColumnHeaders.Add , , "Col2"
ListView1.ColumnHeaders.Add , , "Col3"
Set LI = ListView1.ListItems.Add(, , "Item 1")
LI.SubItems(1) = "Item 1-SubItem 1"
LI.SubItems(2) = "Item 1-SubItem 2"
Set LI = ListView1.ListItems.Add(, , "Item 2")
LI.SubItems(1) = "Item 2-SubItem 1"
LI.SubItems(2) = "Item 2-SubItem 2"
Set LI = ListView1.ListItems.Add(, , "Item 3")
LI.SubItems(1) = "Item 3-SubItem 1"
LI.SubItems(2) = "Item 3-SubItem 2"
End Sub
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lngItemIndex As Long
Dim lngSubItemIndex As Long
Dim strSubItemContent As String
GetLVCellData ListView1, X, Y, strSubItemContent, lngItemIndex, lngSubItemIndex
MsgBox "You clicked Item # " & lngItemIndex & ", SubItem # " & lngSubItemIndex & "." _
& vbNewLine _
& "Contents: " & strSubItemContent
End Sub
In the Module:
VB Code:
Option Explicit
Private Const LVM_FIRST As Long = &H1000
Private Const LVM_HITTEST As Long = (LVM_FIRST + 18)
Private Const LVM_SUBITEMHITTEST As Long = (LVM_FIRST + 57)
Private Const LVHT_ONITEMICON As Long = &H2
Private Const LVHT_ONITEMLABEL As Long = &H4
Private Const LVHT_ONITEMSTATEICON As Long = &H8
Private Const LVHT_ONITEM As Long = (LVHT_ONITEMICON Or _
LVHT_ONITEMLABEL Or _
LVHT_ONITEMSTATEICON)
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type LVHITTESTINFO
pt As POINTAPI
flags As Long
iItem As Long
iSubItem As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'-----------------------------------------------------------------------------
Public Sub GetLVCellData(pobjLV As ListView, _
psngX As Single, _
psngY As Single, _
ByRef pstrCellText As String, _
ByRef plngItemIndex As Long, _
ByRef plngSubItemIndex As Long)
'-----------------------------------------------------------------------------
Dim HTI As LVHITTESTINFO
Dim lst As ListItem
With HTI
.pt.X = (psngX \ Screen.TwipsPerPixelX)
.pt.Y = (psngY \ Screen.TwipsPerPixelY)
.flags = LVHT_ONITEM
End With
SendMessage pobjLV.hwnd, LVM_SUBITEMHITTEST, 0, HTI
If (HTI.iItem > -1) Then
Set lst = pobjLV.ListItems(HTI.iItem + 1)
plngItemIndex = HTI.iItem + 1
plngSubItemIndex = HTI.iSubItem
If HTI.iSubItem = 0 Then
pstrCellText = pobjLV.ListItems(HTI.iItem + 1).Text
Else
pstrCellText = pobjLV.ListItems(HTI.iItem + 1).SubItems(HTI.iSubItem)
End If
Else
pstrCellText = ""
plngItemIndex = 0
plngSubItemIndex = 0
End If
End Sub
"It's cold gin time again ..."
Check out my website here.
-
Aug 17th, 2004, 12:23 PM
#5
Thanks BruceG. I have found another example here,
but it does not correctly work when the columns are resized to
the point that there needs a horizontal scrollbar displayed. Its
like everything is scrolled but the hittest method does not
compenstate for the shift.
I will try out your example, but does it compensate for the
horizontal scrollbar issue?
Thanks again.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Aug 17th, 2004, 12:30 PM
#6
I hadn't tried that before, but I just did and it works fine; the scrollbar should not be an issue.
"It's cold gin time again ..."
Check out my website here.
-
Aug 17th, 2004, 12:36 PM
#7
YES IT WORKS CORRECTLY!!!
Thanks allot BruceG.
One other thing, is it possible to invoke the .LabelEdit method on
a subitem or do I have to present a textbox at the subitem
location as a simulation?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Aug 17th, 2004, 12:40 PM
#8
Ah yes, the rest of the story ... as far as I know, you CANNOT invoke LabelEdit on a SubItem, only the main item. I believe you'll have to do the floating textbox thing ...
"It's cold gin time again ..."
Check out my website here.
-
Aug 17th, 2004, 12:57 PM
#9
Thanks.
I didn't want to be wasting time going down a dead end.
BTW: You should CodeBank your code! There wasn't any working
submissions yet.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Aug 18th, 2004, 07:54 AM
#10
Originally posted by RobDog888
YES IT WORKS CORRECTLY!!!
Thanks allot BruceG.
One other thing, is it possible to invoke the .LabelEdit method on
a subitem or do I have to present a textbox at the subitem
location as a simulation?
It is possible if you are using subclassing i think. I have seen some example in C++, but not in VB. There are some example of C++ implementation in CodeGuru, here is one http://www.codeguru.com/Cpp/controls...cle.php/c1077/
My C++ API skills are not the greatest, so i wouldnt dare trying to port i it to VB. Any one wants to try out.
I think placing a control over subitem for editing is better, this way you get more control, e.g placing a combo box, datetime picker etc....
Rob, did you manage to place a text box control over sub item correctly? I cant seem to get the co-ordinates of the SubItem properly. Would it be possible to post your code?
Thanks.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by :
-
Aug 18th, 2004, 11:15 AM
#11
Here is my other thread that will give you more info on getting
the subitem rect and placing a textbox in it to simulate the label
edit. I will clean up and make a demo for you. Then I will post it there.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|