Results 1 to 7 of 7

Thread: Checking an Item In the Check List Box

  1. #1
    nabbyg is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    May 2005
    Posts
    16
    Reputation
    115

    Checking an Item In the Check List Box

    Hey... everybody

    I am comparing the items in a checklist box to another list of items. If certain conditions are stified then I m setting then I am setting an item as checked (programmatically) in the Checklist box.

    I put a breakpoint right after I check an item in the checklist box, and then I opened the properties for the checklist box in the debug window.

    I saw that the property called CheckedIndices.count = 1.

    I even put a breakpoint at the Itemcheck event for that particular checklistbox, and the program does go there when I programatically check an item in the checklistbox.

    When the form actually loads, I do not see any checks on the form. Is there some property that I have activate for the checks to be visible ??

    Code:
    JobInstrumentCheckList.SetItemCheckState(0, CheckState.Checked)

  2. #2
    kulrom's Avatar
    kulrom is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 3.5
    Join Date
    May 2005
    Location
    Republic of Macedonia
    Posts
    2,855
    Reputation
    263
    there is not property that you have to activate for the checks to be visible ... they are visible by default ... but you can post some code as we could find the possible error ... Cheers

  3. #3
    nabbyg is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    May 2005
    Posts
    16
    Reputation
    115
    Hey Man,

    Here is the code:


    Code:
     
    *****FORM LOAD**************
     
     
     
     
    Private Sub RepairOrderSystemForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     
    'pull all the data from the database, the customer search should
     
    'be taking care of this. Whenever we double click on a job
     
    'the page load load should be given a job ID and then Grab
     
     
     
     
     
    'Get the values for the actuator, valve, Instrument and accessories
     
    'And populate the List boxes and the combo boxes. 
     
     
     
     
     
     
     
    PopulateBoxes("Valve", JobValveCombo)
     
    PopulateBoxes("Actuator", JobActuatorCombo)
     
    PopulateBoxes("Accessory", JobAccessoryCheckList)
     
    PopulateBoxes("Instrument", JobInstrumentCheckList)
     
     
     
    StatusIndex = 0
     
     
     
    Dim i As Integer
     
    For i = 1 To (Me.TabControl1.TabPages.Count() - 1)
     
    Me.TabControl1.TabPages(i).Enabled = False
     
    Next i
     
     
     
    If Not JobId.Text = "" Then
     
    'Call the function that will do the checks for items in the database
     
    SelectChosen(JobId.Text)
     
    End If
     
     
     
    End Sub
    Code:
    ********Populate Boxes Function**************
     
     
     
     
     
     
    
    
    
    Public Sub PopulateBoxes(ByVal type As String, ByVal obj As Object) Try Dim proc As New RepairItemProcessor Dim aList As ArrayList 'The only reason for this TempList, is to have a '"Select An Item" Choice Dim TempList As New ArrayList Dim anitem As New RepairItem anitem.RepairItemName = "Select an Item" TempList.Add(anitem) aList = proc.getRepairItemList(type) If Not aList Is Nothing AndAlso aList.Count > 0 Then If type = "Instrument" Or type = "Accessory" Then obj.DisplayMember = "RepairItemName" obj.ValueMember = "Mechanism" obj.DataSource = aList Else TempList.AddRange(aList) obj.DisplayMember = "RepairItemName" obj.ValueMember = "Mechanism" obj.DataSource = TempList End If End If Catch ex As Exception Throw New Exception("AccessDBError", ex) End Try End Sub












    Code:
     
    *********Select Chosen Function*****************
    Code:
    
     
     
    
    
    
    Public Sub SelectChosen(ByVal JobId As String)Dim proc As New Job_xref_RepaitItemProcessor Dim proc2 As New RepairItemProcessor Dim ChosenOnes As ArrayList Dim AllTheOnes As ArrayList 'Go to the database and grab the list of the repair items 'selected. Display the selected items on the Main Form ChosenOnes = proc.getRepairItemList(JobId) 'Dim ChosenCount As Int16 = ChosenOnes.Count choose(ChosenOnes, JobActuatorCombo) choose(ChosenOnes, JobValveCombo) choose(ChosenOnes, JobInstrumentCheckList, True) choose(ChosenOnes, JobAccessoryCheckList, True) JobInstrumentCheckList.SetItemCheckState(0, CheckState.Checked) JobInstrumentCheckList.SetItemCheckState(1, CheckState.Checked) JobInstrumentCheckList.SetItemCheckState(2, CheckState.Checked) JobInstrumentCheckList.SetItemCheckState(3, CheckState.Checked)
    End Sub











    Code:
     
    *****Choose Function*******************
    Public Sub choose(ByVal obj As Object, ByVal obj2 As Object, Optional ByVal IsInstrument As Boolean = False)
     
    Dim ChosenCount As Int16 = obj.Count 
     
     
     
    'update(chosenones,Jobactuatorcombo)
     
    Dim AllCount As Int16 = obj2.Items.Count
     
     
     
     
     
    For I As Integer = 0 To (ChosenCount - 1)
     
     
     
    For J As Integer = 0 To (AllCount - 1)
     
    If IsInstrument Then
     
    'dealing with the checklist boxes
     
    If obj(I).RepairItemName = obj2.Items.Item(J).RepairItemName Then
     
    ' obj2.SetItemChecked(J, True)
     
     
     
    End If
     
    Else
     
    'Dealing with the combo boxes
     
    If obj(I).RepairItemName = obj2.Items.Item(J).RepairItemName Then
     
    obj2.SelectedItem = obj2.Items.Item(J)
     
    End If
     
    End If
     
    Next
     
     
     
    Next
    Code:
    
    End Sub
     
    
    
     
     
     
    
    
    










  4. #4
    kulrom's Avatar
    kulrom is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 3.5
    Join Date
    May 2005
    Location
    Republic of Macedonia
    Posts
    2,855
    Reputation
    263
    Wow, That's too much code for reading!
    Ok, I will try to find the bug and fix it anyway ... as I don't know if I have enough free time to do so.

    Kind regards

  5. #5
    nabbyg is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    May 2005
    Posts
    16
    Reputation
    115
    hey man.... sorry about the code... if you could just tell me about the behaviour of the check list boxes. why would the state go to unchecked after being checked??

    When the item does "uncheck", should the item check event be raised??

    Thanks,
    Nabby

  6. #6
    nabbyg is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    May 2005
    Posts
    16
    Reputation
    115
    Hey I think I have the problem identified.
    In my application, I have a parent form and a child form. The parent form loads before the child form, and the checklist box is in the child form.

    I tried to activate "Child Form" individually, therefore it opened as a seperate window, but the checklist WORKED. I can see the checked item in the new window. For some reason the values of the checklist box is not being passed along if I have the "frm.mdiparent" property set. Is there a way to pass all the properties when I am creating an MDI child.

    Thanks,
    Nabby

  7. #7
    nabbyg is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    May 2005
    Posts
    16
    Reputation
    115

    Thumbs up

    Finally the problem is solved. Apparently there is bug in .NET with the Tab Control. Therefore I used the code :

    "Tabpage.BindingContext = Me.BindingContext"
    This alsoprovides the funtionality to remember the checked items when we are jumping between tabs on a page.

    This caused a lot of problems since yesterday. Feels good to finally have it working.

    Nabby

Bookmarks

Posting Permissions

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