Results 1 to 6 of 6

Thread: Repaint control ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234

    Question Repaint control ?

    This si my problem: I have checkedlistbox with about 25 items, when I need to check some items from code like this
    For i = 0 To chklstbox.Items.Count - 1
    chklstbox.SelectedIndex = i
    if condition then chklstbox.SetItemChecked(i, True)
    Next i
    control flicker on the screen. Question is how to avoid that flickering?
    In vb6 some controls (like msflexgrid) have property 'Redraw', when it's set to false controls don't redraw on the screen when some changes are perform.

    regard j

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i dont thing the best way to do taht is putting "chklstbox.SelectedIndex = i"..althogu i've never used that control there should be another way to loop thru all the items of the listbox or not?
    \m/\m/

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234
    PT Exorcist said:
    i've never used that control there should be another way to loop thru all the items of the listbox or not?
    Did anybody know that 'another way'?

    regard j

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Try this

    VB Code:
    1. [b]chklstbox.BeginUpdate[/b]
    2.  
    3. For i = 0 To chklstbox.Items.Count - 1
    4.     chklstbox.SelectedIndex = i
    5.     if condition then chklstbox.SetItemChecked(i, True)
    6. Next i
    7.  
    8. [b]chklstbox.EndUpdate[/b]
    This world is not my home. I'm just passing through.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234
    I tried, that doesn't work.

    regard j

  6. #6
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    ok then, try this.


    VB Code:
    1. Dim i As Integer
    2.         Dim clb As New CheckedListBox()
    3.         Dim bln As Boolean
    4.  
    5.         Cursor.Current = Cursors.WaitCursor
    6.         chklstbox.BeginUpdate()
    7.  
    8.         For i = 0 To chklstbox.Items.Count - 1
    9.             clb.Items.Add(chklstbox.Items(i))
    10.         Next
    11.  
    12.         chklstbox.Items.Clear()
    13.  
    14.         For i = 0 To clb.Items.Count - 1
    15.             bln = CBool(i Mod 3 = 1) 'condition
    16.             chklstbox.Items.Add(clb.Items(i), bln)
    17.         Next
    18.  
    19.         chklstbox.EndUpdate()
    20.         Cursor.Current = Cursors.Default
    This world is not my home. I'm just passing through.

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