VisualBlogger CategoryPost Test #9

The WinForms adventure continues. The CheckedListBox control has been giving me all sorts of problems. For one thing, if you put one in a TabControlPage, and then switch pages, it doesn't hold its state. It took me a little bit of experimentation, but I came up with the following code to help out:

1    Dim chk1 As New ArrayList

2 Dim chk2 As New ArrayList
3
4#Region " OptionsTabPage.Leave Event Handler "

5
6 Private Sub OptionsTabPage_Leave(ByVal sender As Object, ByVal e As System.EventArgs)
Handles OptionsTabPage.Leave
7 chk1.Clear()
8 chk2.Clear()
9 Dim tmpChk1 As CheckedListBox.CheckedIndexCollection = BlogList.CheckedIndices
10 For y As Integer = 0 To tmpChk1.Count - 1
11 chk1.Add(tmpChk1.Item(y))
12 Next
13 Dim tmpChk2 As CheckedListBox.CheckedIndexCollection = CategoryList.CheckedIndices
14 For z As Integer = 0 To tmpChk2.Count - 1
15 chk2.Add(tmpChk2.Item(z))
16 Next
17 End Sub
18#End Region
19
20#Region " Tab Control Page Changed Event "

21
22 Private Sub ViewTabControl_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles ViewTabControl.SelectedIndexChanged
23 Dim currentPage As TabControl = CType(sender, TabControl)
24 Select Case currentPage.SelectedTab.Name
25 Case "OptionsTabPage"
26 Try
27 For y As Integer = 0 To chk1.Count - 1
28 BlogList.SetItemChecked(chk1(y).ToString, True)
29 Next
30 Catch
31 End Try
32 Try
33 For z As Integer = 0 To chk2.Count - 1
34 CategoryList.SetItemChecked(chk2(z).ToString, True)
35 Next
36 Catch
37 End Try
38 End Select
39 End Sub
40#End Region
At any rate, this port is a test of the "PostToCategories" functionality. Now that I'm saving the state properly, and using the "CheckedIndices" property instead of "SelectedIndices" property, it should work. I'll know in about 8 seconds.

No Comments