Results 1 to 33 of 33

Thread: [RESOLVED] Only show certain items on LV based on category text in file?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Resolved [RESOLVED] Only show certain items on LV based on category text in file?

    hi

    i want to show only LV items if the category text in file matches nscombobox1.text..... here's my code:

    Code:
    Imports System, System.Xml, System.Collections.Generic
    Imports System.ComponentModel, System.Data, System.Drawing, System.Text
    Imports System.Windows.Forms, System.IO
    
    Public Class SelectPrograms
    
        'App Name              : Post Install
        'Author                : Chris Reynolds (Chris2k)
        'Creation Date         : 26th March 2013
    
        Public Shared Ver As String = "v1.3.1"
        Public Shared programs As Dictionary(Of Integer, program) = New Dictionary(Of Integer, program)
    
        Dim autoStart As Integer
        Dim highestIO As Integer = 0
        Dim F As Form = FindForm()
    
    #Region "Dropdown menu"
        Private Sub MenuDrop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuDrop.Click
            Menu1.Show(MenuDrop, 0, MenuDrop.Height)
        End Sub
    
        Private Sub CheckItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckItem.Click
            If chkSelect.Checked = True Then
                chkSelect.Checked = False
                For i = 0 To AppsList.Items.Length - 1
                    AppsList.CheckBoxChecked(i) = False
                Next
            Else
                chkSelect.Checked = True
                For i = 0 To AppsList.Items.Length - 1
                    AppsList.CheckBoxChecked(i) = True
                Next
            End If
        End Sub
    
        Private Sub TickerItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TickerItem.Click
            chkStopTicker.Checked = True
            chkStopTicker.Enabled = False
            Ticker.Enabled = False
        End Sub
    
        Private Sub EditorItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditorItem.Click
            Editor.Show()
        End Sub
    
        Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
            F.Close()
        End Sub
    
        Private Sub MinimizeItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MinimizeItem.Click
            F.WindowState = FormWindowState.Minimized
        End Sub
    #End Region
    
    #Region "Read the XML file"
        Public Shared XMLFile As String = "Install.xml"
    
        Public Sub ReadFile()
            If Not IO.Directory.Exists(Application.StartupPath + "\Install\") Then
                IO.Directory.CreateDirectory(Application.StartupPath + "\Install\")
            End If
    
            Dim installOrder As Integer = 0
    
            Dim document As XmlReader = New XmlTextReader(XMLFile) 'create a new xmltextreader object, this is the object that we will loop and will be used to read the xml file...
            If IO.File.Exists(XMLFile) Then
                While (document.Read())
                    Try
                        Dim type = document.NodeType
                        If (type = XmlNodeType.Element) Then 'if node type was element
                            If document.Name = "Order" Then
                                installOrder = CInt(document.ReadElementContentAsInt)
                                If installOrder > highestIO Then highestIO = installOrder
                                programs.Add(installOrder, New program)
                            ElseIf document.Name = "Name" Then
                                programs(installOrder).name = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "Description" Then
                                programs(installOrder).desc = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "File" Then
                                programs(installOrder).exepath = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "Forced" Then
                                If document.ReadInnerXml.ToString = "True" Then
                                    programs(installOrder).forceInstall = "True"
                                Else
                                    programs(installOrder).forceInstall = "False"
                                End If
                            ElseIf document.Name = "URL" Then
                                programs(installOrder).url = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "Snap" Then
                                programs(installOrder).screenshot = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "Category" Then
                                programs(installOrder).category = document.ReadInnerXml.ToString()
                                End If
                        End If
                    Catch ex As Exception
    
                    End Try
                End While
            End If
        End Sub
    
        Public Function getFileSize(ByVal path As String) As String
            Dim sizes() As String = New String() {"Bytes", "KiB", "MB", "GB"}
            Dim len = My.Computer.FileSystem.GetFileInfo(path).Length
            Dim order As Integer = 0
    
            While ((len >= 1024) AndAlso (order < sizes.Length))
                order = (order + 1)
                len = CLng((len / 1024))
            End While
            Return String.Format("{0:0.##} {1}", len, sizes(order))
        End Function
    #End Region
    
    #Region "Add info to temporary LV"
        Dim cOrder As Integer = 0
    
        Public Sub AddtoLV()
            Do While (cOrder < (highestIO + 1))
                Try
                    If Not programs.ContainsKey(cOrder) Then
                        Continue Do
                    End If
    
                    Dim program As program = programs(cOrder)
                    If Not (program) Is Nothing AndAlso program.name.Length > 0 Then
                        If IO.File.Exists(program.exepath) Then
                            Dim appData As ListViewItem = New ListViewItem(program.name)
                            appData.SubItems.Add(program.desc)
                            appData.SubItems.Add(getFileSize(program.exepath))
                            appData.SubItems.Add(program.exepath)
                            appData.SubItems.Add(program.url)
                            appData.SubItems.Add(program.screenshot)
                            appData.SubItems.Add(program.forceInstall)
                            appData.SubItems.Add(program.category)
                            appData.Checked = True
                            ListView1.Items.Add(appData)
                        Else
                            '"Installer file for program '" + (program.name + "' could not be found!"
                        End If
                    Else
                        '"Failed to load program from order: " + (cOrder + "..!"
                    End If
                Catch ex As Exception
    
                Finally
                    cOrder = (cOrder + 1)
                End Try
            Loop
        End Sub
    #End Region
    
    #Region "Settings"
        Public Sub Settings()
            If Setup.TickerOnOff.Checked = True Then
                chkStopTicker.Visible = True
                autoStart = CInt(Setup.txtTickerSecs.Text)
            Else
                chkStopTicker.Visible = False
                autoStart = 0
            End If
    
            If Setup.ToggleMI.Checked = True Then
                chkMiniInstaller.Visible = True
            Else
                chkMiniInstaller.Visible = False
            End If
        End Sub
    #End Region
    
    #Region "Fade Setting"
        Sub FormFade(ByVal FType As String)
            Select Case FType
                Case "in"
                    Dim FadeCount As Integer
                    For FadeCount = 10 To 75 Step 10
                        Me.Opacity = FadeCount / 100
                        Me.Refresh()
                        Threading.Thread.Sleep(50)
                    Next
                Case "out"
                    Dim FadeCount As Integer
                    For FadeCount = 75 To 10 Step -10
                        Me.Opacity = FadeCount / 100
                        Me.Refresh()
                        Threading.Thread.Sleep(50)
                    Next
            End Select
            Me.Opacity = 95.9
        End Sub
    #End Region
    
        Private Sub SelectPrograms_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Me.Text = "Post Install " + Ver
            Me.NsTheme.Text = "Post Install " + Ver
    
            FormFade("in")
    
            Settings()
    
            ReadFile()
    
            AddtoLV()
    
            For Each App As ListViewItem In ListView1.Items
                AppsList.AddItem(App.Text,
                                 (App.SubItems(1).Text),
                                 (App.SubItems(2).Text),
                                 (App.SubItems(3).Text),
                                 (App.SubItems(4).Text),
                                 (App.SubItems(5).Text),
                                 (App.SubItems(6).Text),
                                 (App.SubItems(7).Text))
            Next
    
            For i = 0 To AppsList.Items.Length - 1
                AppsList.CheckBoxChecked(i) = True
                Dim subItems = AppsList.SubItems(i)
                If subItems(5).Text = "True" Then
                    AppsList.CheckBoxEnabled(i) = False
                End If
            Next
    
            Dim line() As String = Split(Setup.txtCategories.Text, vbCrLf)   '~~~ Split the lines and store it in a String array
    
            For i = 2 To UBound(line)  '~~~ Loop through the array
                NsComboBox1.Items.AddRange(line)         '~~~ and add each item(ie. line) to the combobox
            Next
            NsComboBox1.SelectedIndex = 0
    
            Version.Text = Ver
            btnStart.Text = "Start installing (" & AppsList.CheckedItemsCount.ToString() & " / " & AppsList.Items.Length.ToString & " applications)"
        End Sub
    
    
        Private Sub SelectPrograms_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            FormFade("out")
        End Sub
    
        Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
            If AppsList.CheckedItemsCount > 0 Then
                Me.Hide()
                InstallPrograms.Show() '//Load in the form and install checked apps.
            Else
                NSMessageBox.ShowOk("Nothing selected to install!", "")
            End If
        End Sub
    
        Private Sub Ticker_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ticker.Tick
            If autoStart > 0 Then
                autoStart -= 1
                chkStopTicker.Text = "Stop ticking (" + autoStart.ToString & " Secs Remaining!)"
                chkStopTicker.Refresh()
            ElseIf autoStart = 0 Then
                Ticker.Stop()
                chkStopTicker.Enabled = False
                'Label2.Text = "We're gonna install now..."
                Me.Hide()
                InstallPrograms.Show()
            End If
        End Sub
    
        Private Sub AppsList_CheckedChanged(ByVal sender As Object) Handles AppsList.CheckedChanged
            Me.btnStart.Text = "Start installing (" & AppsList.CheckedItemsCount.ToString() & " / " & AppsList.ItemsCount.ToString() & " applications)"
            btnStart.Refresh()
        End Sub
    
        Private Sub AppsList_SelectedIndexChanged(ByVal Index As Integer) Handles AppsList.SelectedIndexChanged
            Dim selectedItems = Me.AppsList.SelectedItems
            If selectedItems.Length > 0 Then
                Dim sb As New StringBuilder
                Dim format As String = "{0}" & Environment.NewLine +
                                       "Size: {1}" & Environment.NewLine & Environment.NewLine &
                                       "Description: {2}" & Environment.NewLine &
                                       "Support URL: {3}"
    
                For Each sItem In selectedItems
                    sb.AppendLine(String.Format(format,
                                                sItem.Text,
                                                sItem.SubItems(1).Text,
                                                sItem.SubItems(0).Text,
                                                sItem.SubItems(3).Text)) 'App Name, Description, Size, Support URL...
    
                    Me.Screenshot.Image = Image.FromFile(sItem.SubItems(4).Text)
                Next
    
                lblDcription.Text = sb.ToString
            End If
        End Sub
    
        Private Sub chkStopTicker_CheckedChanged(ByVal sender As Object) Handles chkStopTicker.CheckedChanged
            If chkStopTicker.Checked = True Then
                Ticker.Stop()
                Ticker.Enabled = False
                chkStopTicker.Enabled = False
            Else
                Ticker.Start()
            End If
        End Sub
    
        Private Sub Label1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblDcription.SizeChanged
            Label2.Top = lblDcription.Height
        End Sub
    
        Private Sub NsvScrollBar1_Scroll(ByVal sender As System.Object) Handles NsvScrollBar1.Scroll
            Panel.VerticalScroll.Value = NsvScrollBar1.Value
        End Sub
    
        'Private Sub NsComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NsComboBox1.SelectedIndexChanged
        'If AppsList.ItemsCount > 0 Then
        '    Dim program As program = programs(cOrder)
        '    If Not NsComboBox1.Text = program.category Then
        '        '~~~ Hide the item....
        '        AppsList.ItemsClear()
        '    End If
        'End If
        'End Sub
    End Class
    
    Public Class program
        Public order As Integer = 0
        Public name As String = ""
        Public desc As String = ""
        Public exepath As String = ""
        Public screenshot As String = ""
        Public filesize As Integer
        Public forceInstall As String = ""
        Public url As String = ""
        Public category As String = ""
    
        Public Sub New()
            MyBase.New()
        End Sub
    End Class
    I've highlited what i rtried.....

    any help...?

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,949

    Re: Only show certain items on LV based on category text in file?

    Hi,

    Since the items from the listview came from a Dictionary object, why not extract the information again
    from the dictionary during combo box selected index changed event is triggered, and display it again
    to listview? Or, are you trying to hide/show the listview items dynamically?
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Could u show me what u mean by 'extract again'...

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,949

    Re: Only show certain items on LV based on category text in file?

    I mean, retrieve the records from the Dictionary object since the listviews' items source depends
    on the Dictionary object right?
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Ok i think i got ya... But it's not working, check me code, i've highlighted:

    Code:
    #Region "Read the XML file"
        Public Shared XMLFile As String = "Install.xml"
    
        Public Sub ReadFile()
            If Not IO.Directory.Exists(Application.StartupPath + "\Install\") Then
                IO.Directory.CreateDirectory(Application.StartupPath + "\Install\")
            End If
    
            Dim installOrder As Integer = 0
            Dim document As XmlReader = New XmlTextReader(XMLFile) 'create a new xmltextreader object, this is the object that we will loop and will be used to read the xml file...
    
            Dim lines() As String = Split(Setup.txtCategories.Text, vbCrLf)   '~~~ Split the lines and store it in a String array
            For i = 0 To lines.Length - 1
                Me.NsComboBox1.Items.Add(lines(i))         '~~~ and add each item(ie. line) to the combobox
            Next
            Me.NsComboBox1.SelectedIndex = 0
    
            If IO.File.Exists(XMLFile) Then
                While (document.Read())
                    Try
                        Dim type = document.NodeType
                        If (type = XmlNodeType.Element) Then 'if node type was element
                            If document.Name = "Order" Then
                                installOrder = CInt(document.ReadElementContentAsInt)
                                If installOrder > highestIO Then highestIO = installOrder
                                programs.Add(installOrder, New program)
                            ElseIf document.Name = "Name" Then
                                programs(installOrder).name = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "Description" Then
                                programs(installOrder).desc = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "File" Then
                                programs(installOrder).exepath = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "Forced" Then
                                If document.ReadInnerXml.ToString = "True" Then
                                    programs(installOrder).forceInstall = "True"
                                Else
                                    programs(installOrder).forceInstall = "False"
                                End If
                            ElseIf document.Name = "URL" Then
                                programs(installOrder).url = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "Snap" Then
                                programs(installOrder).screenshot = document.ReadInnerXml.ToString()
                            ElseIf document.Name = "Category" Then
                                programs(installOrder).category = document.ReadInnerXml.ToString()
                                If Not NsComboBox1.Text = programs(installOrder).category Then
                                    '~~~ Hide the item....
                                    AppsList.ItemsClear()
                                End If
                            End If
                        End If
                    Catch ex As Exception
                        Dim err As String = "FFS! What's wrong now?"
                    End Try
                End While
            End If
        End Sub
    
        Private Sub NsComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NsComboBox1.SelectedIndexChanged
            If AppsList.ItemsCount > 0 Then
                ReadFile()
                AppsList.Refresh()
            End If
        End Sub
    -
    Last edited by chris-2k; Dec 9th, 2013 at 04:11 PM.

  6. #6
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,949

    Re: Only show certain items on LV based on category text in file?

    Code:
    If Not (NsComboBox1.Text.Equals(programs(installOrder).category)) Then
      AppsList.Items.Clear() 'you forgot the dot when calling Clear()
    EndIf
    KG
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    That doesn't work m8...

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    try this. in nscombobox1_selectedindexchanged you need to clear + reload the listview:

    Code:
    Public Sub AddtoLV()
        Do While (cOrder < (highestIO + 1))
            Try
                If Not programs.ContainsKey(cOrder) Then
                    Continue Do
                End If
    
                Dim program As program = programs(cOrder)
                If Not (program) Is Nothing AndAlso program.name.Length > 0 Then
                    If programs(cOrder).Category = nscombobox1.text then
                        If IO.File.Exists(program.exepath) Then
                            Dim appData As ListViewItem = New ListViewItem(program.name)
                            appData.SubItems.Add(program.desc)
                            appData.SubItems.Add(getFileSize(program.exepath))
                            appData.SubItems.Add(program.exepath)
                            appData.SubItems.Add(program.url)
                            appData.SubItems.Add(program.screenshot)
                            appData.SubItems.Add(program.forceInstall)
                            appData.SubItems.Add(program.category)
                            appData.Checked = True
                            ListView1.Items.Add(appData)
                        Else
                            '"Installer file for program '" + (program.name + "' could not be found!"
                        End If
                    End If
                Else
                    '"Failed to load program from order: " + (cOrder + "..!"
                End If
            Catch ex As Exception
    
            Finally
                cOrder = (cOrder + 1)
            End Try
        Loop
    End Sub

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    should i replace my sub .paul and where to clear?

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    yeah replace the sub.

    2/

    Code:
    Private Sub nscombobox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nscombobox1.SelectedIndexChanged
        ListView1.Items.clear()
        AddtoLV()
    End Sub

  11. #11
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,254

    Re: Only show certain items on LV based on category text in file?

    Quote Originally Posted by chris-2k View Post
    That doesn't work m8...
    Why would it? It doesn't work because you're using a custom LV control which is NOT inherited from a VB LV so it doesn't have the same methods as a VB LV nor does it even work exactly the same as a VB LV, How many times do I have to tell you that?

    I asked you to mention in your title or posts that you are using this custom control so everyone knows what you are talking about, but once again you post code with no mention of it and just wasting everyones time.

  12. #12
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    did my code work?
    I didn't know it was a custom listview, but the filtering should still work. not sure how you'd clear though...

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Edge, i didn't mention about the LV as this thread don't really involve the LV, only the ItemsClear()..

    .paul, it works when i debug for the category selected, then i change category, all items clear permanent...

  14. #14
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    the code I gave you would work properly with a standard combobox + a standard listview.
    you need to modify it, in accordance with the properties + methods of your custom controls

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Well as far as im aware the Nscombobox is inherited, so it should be standard...?

    hmm the LV's Clear method is no different, just a syntax change to ItemsClear().....

    Are u sure th code works?

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?


  17. #17
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    move:

    Code:
    Dim cOrder As Integer = 0
    inside of the AddtoLV procedure (first line) so it's a local variable instead of a form level variable

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Brilliant, it's working.....

    OK you may have seen i'm counting checked items aswell as all items, so when i change category, they reset.... Any fix....

  19. #19
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    try this:

    Code:
    Private Sub SelectPrograms_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Text = "Post Install " + Ver
        Me.NsTheme.Text = "Post Install " + Ver
    
        'FormFade("in")
    
        Settings()
    
        ReadFile()
        AddtoLV()
    
        Version.Text = Ver
        getCheckedItemsCount()
    
    End Sub
    
    Private Sub AppsList_CheckedChanged(ByVal sender As Object) Handles AppsList.CheckedChanged
        getCheckedItemsCount()
        btnStart.Refresh()
    End Sub
    
    Private Sub NsComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NsComboBox1.SelectedIndexChanged
        AppsList.ItemsClear()
        'ReadFile()
        AddtoLV()
        AppsList.Refresh()
        getCheckedItemsCount()
    End Sub
    
    Private Sub getCheckedItemsCount()
        btnStart.Text = "Start installing (" & AppsList.CheckedItemsCount.ToString() & " / " & AppsList.Items.Length.ToString & " applications)"
    End Sub

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Nope still same....

    In the worst case, it'd aftobe static.. but then im thinking that only selected category items will go to installprogram form....

    ItemsClear() is the *****, we need a sub just to hide items....

  21. #21
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,254

    Re: Only show certain items on LV based on category text in file?

    Quote Originally Posted by chris-2k View Post
    Edge, i didn't mention about the LV as this thread don't really involve the LV, only the ItemsClear()..
    Yes, and so there would be no need for posts like #6 if you would've mentioned that in your first post.
    Good luck with the project.

  22. #22
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    you need to explain exactly what is happening that shouldn't be happening + what isn't happening that should be happening, because i'm not sure how your program is supposed to be working.
    I tried debugging AddtoLV + programs only contains 2 items. is that right? it seems there should be more items...

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Yea there's only 2 for now as im testing, 3 category's with 1 empty OK..

    the problem is when i switch category the checked count would reset and only the seleced category items will go to installprograms form hence ItemsClear()....

    we need to hide items only not clear....

  24. #24
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    you want to keep items selected when not visible in the listview if I understand you correctly?
    i'd add a Boolean checked field to the program class, which you'd set + unset in the AppsList_CheckedChanged eventhandler, + when loading your installprograms form, use the programs dictionary to get selected items instead of the listview.

  25. #25

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    sorry you've lost me, can u show me what u mean with a boolean....

  26. #26
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    it's simple English...
    how have you got this far with your app not understanding some basic coding techniques?
    I've seen your application before, but it was so long ago, I didn't think it was the same app.

    ok rant over

    Code:
    Public Class program
        Public order As Integer = 0
        Public name As String = ""
        Public desc As String = ""
        Public exepath As String = ""
        Public screenshot As String = ""
        Public filesize As Integer
        Public forceInstall As String = ""
        Public url As String = ""
        Public category As String = ""
        Public checked As Boolean
    
        Public Sub New()
            MyBase.New()
        End Sub
    End Class
    there's the Boolean field. when you read your xml file, you'll probably want to set it. it's false by default.

    if I've completely misunderstood you, I apologize.

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    No .paul don't say sorry, i'm the noob.....

    I've done that and also added to the ReadFile sub:
    Code:
                                ElseIf programs(installOrder).checked = False Then
                                    programs(installOrder).checked = True
    now im failing too see how tthis counts other category items, when they've cleared.....

  28. #28
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    Let me check before I make any further suggestions...
    You have all of your items, divided into categories. When your app loads, you want all items selected, but your user can switch between categories + select or deselect items.
    When your user opens the install form, you want to list + install all selected items from the entire programs dictionary.

    Do I understand what you're trying to do, because going round in circles is very frustrating for you, me, + anyone else that tries to help.

  29. #29

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Yes, right on .paul...

    also want to count checked items...

  30. #30
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    Right ok. Now we're clear, I'll have another look at it

  31. #31
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?


  32. #32

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Only show certain items on LV based on category text in file?

    Thank u .paul, so now my installprograms form will install all checked items in all categorys?

  33. #33
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,500

    Re: Only show certain items on LV based on category text in file?

    yep.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width