Results 1 to 2 of 2

Thread: How to determine selected items in Check list box?

  1. #1

    Thread Starter
    Fanatic Member sbasak's Avatar
    Join Date
    Aug 2001
    Location
    Globe Trotter
    Posts
    524

    Exclamation How to determine selected items in Check list box?

    I having trouble with recognizing selected items in Check List Box.
    For example, I want the following code to print the only non selected items in a file. However the line "If Not chkToDo.Items.Item(j).checked Then" is not working. In fact, I don't find any drop down after Item(). - I'm only getting GetType().

    Can anyone show light??

    Thanx


    Public Sub WriteToDoInFile()
    'write to do unchecked lists in file
    Dim i, j As Integer
    i = chkToDo.Items.Count
    Try
    FileOpen(2, "ToDo.txt", OpenMode.Output)
    For j = 0 To i - 1
    If Not chkToDo.Items.Item(j).checked Then
    Print(2, chkToDo.Items.Item(j) & vbCrLf)
    End If
    Next
    FileClose(2)
    Catch x As System.Exception
    MessageBox.Show(x.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
    End Sub
    Life is a one way journey, not a destination. Travel it with a smile and never regret anything.
    Yesterday is history, tomorrow is a mystery, today is gift - that's why we call it present.

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    you mean this :
    VB Code:
    1. Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
    2.         Dim x As Integer, i As Integer
    3.         For x = 0 To CheckedListBox1.Items.Count - 1
    4.             i = CheckedListBox1.GetItemCheckState(x)
    5.             If Not i = 1 Then
    6.                 '/// it's not checked , so do stuff
    7.             Else
    8.                 MessageBox.Show(CheckedListBox1.Items(x) & "  :this is checked!")
    9.             End If
    10.         Next
    11.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

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