11/30/2018 0 Comments Edit Listview Subitem In Vb6 SourceHi TeachMe, According to your description, you'd like to add a Image next to the string in the listview item. I suggest you redrawing the Item of ListView. First you should change the OwnDraw property of the ListView to True. Then use the and event handler to redraw the item. Here is a sample for you. Private Sub ListView1_DrawSubItem(sender As Object, e As DrawListViewSubItemEventArgs) Handles ListView1.DrawSubItem If e.ColumnIndex = 2 Then Dim im As Image = Image.FromFile('YOUR IMAGE PATH') Dim location As Point = Me.listView1.Items(e.ItemIndex).SubItems(e.ColumnIndex).Bounds.Location e.Graphics.DrawImage(im, Location) e.Graphics.DrawString('hi', Me.Font, new SolidBrush(Color.Black), new PointF(location.X + 20, location.Y)) 'Here 20 is the width of your image. E.DrawFocusRectangle(Me.ListView1.Items(e.ItemIndex).SubItems(e.ColumnIndex).Bounds) Else e.DrawText() End If End Sub Private Sub ListView1_DrawColumnHeader(sender As Object, e As DrawListViewColumnHeaderEventArgs) Handles ListView1.DrawColumnHeader e.DrawText() End Sub If you have any other concern regarding this issue, please feel free to let me know. Best regards, Youjun Tang We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click to participate the survey. VB ListView; VB ListBox; VB. But after edit subitem memory leak occurred. Hi Zafir I was wondering if you can post a demo project or the source code for this. Robin, Are you using VB6 and the Listview control from that? If memory serves me correctly, the listitems and subitems are 0 based collections. So if you have 3 columns, they should be indexed 0-2. VB6: Debug.Print ListView1.ListItems(0).SubItem(0).Text Debug.Print ListView1.ListItems(0).SubItem(2).Text If you are using Visual Basic 2005, then you need to change your code since the new control has an Items collection, not a ListItems collection. Here is code for.Net. VB2005: Debug.Print(ListView1.Items(0).SubItems(0).Text) ListView1.Items(0).SubItems(0).Text = 'foo' Adam Braden Visual Basic Team. ![]() If memory serves me correctly, the listitems and subitems are 0 based collections. So if you have 3 columns, they should be indexed 0-2. VB6: Debug.Print ListView1.ListItems(0).SubItem(0).Text Debug.Print ListView1.ListItems(0).SubItem(2).Text If you are using Visual Basic 2005, then you need to change your code since the new control has an Items collection, not a ListItems collection. Here is code for.Net. VB2005: Debug.Print(ListView1.Items(0).SubItems(0).Text) ListView1.Items(0).SubItems(0).Text = 'foo' Adam Braden Visual Basic Team.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |