Can you post your code it will help find your problem...
What type of control are you showing the results of the combobox selection
Some steps to get you started.
1. First create the code that shows all the results. (This makes sure you have a good connection and the underlining code is good)
2. Create the combobox and make sure it has all the opptions (data) you want.
3. At that point deside if you want to filter the data at the data source or in your app. (If the data source is large always filter at the source)
Ok, Here is the code:
Form:
Option
Strict OnOption
Explicit OnPublic
Class frmPatient ' Declaring module level variables Private oldTime As Integer = 0 Private newTime As Integer = 0 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.TickLabel1.Text = TimeString &
" " & DateString End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub Private Sub frmPatient_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'TODO: This line of code loads data into the 'Ntier_SCOADataSet.Resources' table. You can move, or remove it, as needed. Me.ResourcesTableAdapter.Fill(Me.Ntier_SCOADataSet.Resources) ' This sub handles the initial reading of text file. Dim Patient_Info As New List(Of String) Dim record As StringPatient_Info = Module1.ReadTextFile()
' Determine if record should be appended based on timestamp Integer.TryParse(Patient_Info(0), newTime) If newTime > oldTime Or oldTime = 0 Then ' Concatenate stringsrecord = Module1.ConcatenateStrings(Patient_Info)
' Add record to appropriate listModule1.AppendRecord(record, Patient_Info(3))
' set oldTime to newTimeoldTime = newTime
End IfEnd Sub Private Sub UpdateQues(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick, xRefreshButton.Click ' This sub handles the refreshing of data when either the timer expires ' or the xRefreshButton is clicked. ' Note: timer expires in 60000 milliseconds or 1 minute. Dim Patient_Info As New List(Of String) Dim record As String
Patient_Info = Module1.ReadTextFile()
' Determine if record should be appended based on timestamp Integer.TryParse(Patient_Info(0), newTime) If newTime > oldTime Then ' Concatenate stringsrecord = Module1.ConcatenateStrings(Patient_Info)
' Add record to appropriate listModule1.AppendRecord(record, Patient_Info(3))
' set oldTime to newTimeoldTime = newTime
End IfModule1.ShowRecords()
End Sub Private Sub xResourceListBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) ' This sub shows the correct lists when a resource is selected.Module1.ShowRecords()
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xPlacedButton.Click ' This sub is called when the xPlacedButton is clicked ' Note: follow the calls to the appropriate subs or functions. Dim index As Integerindex =
Me.xRecordsListBox.SelectedIndexModule1.MoveToPlaced(index)
End SubEnd
Classmodule1:
Option
Strict OnOption
Explicit OnModule
Module1 ' Declaring module level lists ' Each resource will need two lists. Patient que & Placed List Private AWS As New List(Of String) Private AWS2 As New List(Of String) Private XYG As New List(Of String) Private XYG2 As New List(Of String) Private JBY As New List(Of String) Private JBY2 As New List(Of String) Public Function ReadTextFile() As List(Of String) ' This function reads the text file and parses it appropriately. ' Returns a list to calling function or sub Dim NewInfo As New List(Of String) Dim read_line() As String ' path will be different depending on location of text file Const path As String = "C:\hl7test" Dim temp_MSH_pipes() As String Dim temp_SCH_pipes() As String Dim temp_NTE_pipes() As String Dim temp_PID_pipes() As String Dim temp_AIG_pipes() As String Dim temp_REASON_carrots() As String Dim temp_APPTTIME_carrots() As String Dim temp_STATUS_carrots() As String Dim temp_PATIENT_carrots() As String Dim temp_RESOURCE_carrots() As String Dim patient_Lname As String Dim patient_Fname As String 'NewInfo(0) = file_time 'NewInfo(1) = appt time 'NewInfo(2) = patient full name 'NewInfo(3) = resource 'NewInfo(4) = reason 'NewInfo(5) = status 'NewInfo(6) = current time 'NewInfo(7) = comment ' assign each line of text file to element of arrayread_line =
My.Computer.FileSystem.ReadAllText(path & "\testnl7.txt").Split(Chr(13)) ' splitting first line by pipestemp_MSH_pipes = read_line(0).Split(Chr(124))
' don't need to do anything else except strip out the timestamp ' note: could not use entire number, so I eliminated the year. ' this string is for application purposes and will not be shown on form.NewInfo.Add(temp_MSH_pipes(5).Substring(5))
' splitting second line by pipes into elements of an arraytemp_SCH_pipes = read_line(1).Split(Chr(124))
' splitting preceding array by carrots(^) into elements of another arraytemp_APPTTIME_carrots = temp_SCH_pipes(11).Split(Chr(94))
' strip out the appointment time from correct element of new arrayNewInfo.Add(temp_APPTTIME_carrots(3).Substring(8, 4))
' repeating preceding steps to acquire rest of datatemp_PID_pipes = read_line(3).Split(Chr(124))
temp_PATIENT_carrots = temp_PID_pipes(5).Split(Chr(94))
patient_Lname = temp_PATIENT_carrots(0)
patient_Fname = temp_PATIENT_carrots(1)
' concatenating to namesNewInfo.Add(patient_Lname &
", " & patient_Fname)temp_AIG_pipes = read_line(6).Split(Chr(124))
temp_RESOURCE_carrots = temp_AIG_pipes(3).Split(Chr(94))
NewInfo.Add(temp_RESOURCE_carrots(0))
temp_REASON_carrots = temp_SCH_pipes(6).Split(Chr(94))
NewInfo.Add(temp_REASON_carrots(1))
temp_STATUS_carrots = temp_SCH_pipes(25).Split(Chr(94))
NewInfo.Add(temp_STATUS_carrots(0))
' including timestring into listNewInfo.Add(TimeString)
temp_NTE_pipes = read_line(2).Split(Chr(124))
NewInfo.Add(temp_NTE_pipes(3))
Return NewInfo End Function Public Function GetList(ByVal index As Integer) As List(Of String) ' This function determines which patient list to examine by examining the ' passed index. Returns the correct list to calling function or sub. ' Note: this will have to be expanded to include every resource. Dim CorrectList As New List(Of String) If index = 0 ThenCorrectList = XYG
ElseIf index = 9 ThenCorrectList = AWS
ElseIf index = 22 ThenCorrectList = JBY
End If Return CorrectList End Function Public Function GetList2(ByVal index As Integer) As List(Of String) ' This function determines which placed list to examine by examining the ' passed index. Returns the correct list to calling function or sub. ' Note: this will have to be expanded to include every resource. Dim CorrectList As New List(Of String) If index = 0 ThenCorrectList = XYG2
ElseIf index = 9 ThenCorrectList = AWS2
ElseIf index = 22 ThenCorrectList = JBY2
End If Return CorrectList End Function Public Function ConcatenateStrings(ByVal Patient_List As List(Of String)) As String ' This function takes a list and concatenates it with appropriate spacing for ' Patient list. Returns a record as string. Dim record As Stringrecord = Patient_List(1).PadRight(12, Chr(32)) & Patient_List(2).PadRight(26, Chr(32)) & Patient_List(3).PadRight(11, Chr(32)) & Patient_List(4).PadRight(11, Chr(32)) & Patient_List(5).PadRight(10, Chr(32)) & Patient_List(6).PadRight(10, Chr(32)) & Patient_List(7)
Return record End Function Public Sub AppendRecord(ByVal record As String, ByVal resource As String) ' This sub appends records in the patient que by determining what the resource is. ' These values are passed by the calling function or sub. If resource Like "XYG" ThenXYG.Add(record)
ElseIf resource Like "AWS" ThenAWS.Add(record)
ElseIf resource Like "JBY" ThenJBY.Add(record)
End IfEnd Sub Public Sub AppendRecord2(ByVal index As Integer, ByVal record As String) ' This sub appends records in the Placed list by determining what the resource is. ' These values are passed by the calling function or sub. If index = 0 Then
XYG2.Add(record)
ElseIf index = 9 ThenAWS2.Add(record)
ElseIf index = 22 ThenJBY2.Add(record)
End IfEnd Sub Public Sub ShowRecords() ' This sub shows the records for the appropriate resource Dim show_who As Integer Dim i As Integer Dim my_list As New List(Of String) ' determine who is selected
show_who = frmPatient.xCheckedListBox1.SelectedIndex()
' get the correct listmy_list = GetList(show_who)
' clear out the Top list boxfrmPatient.xCheckedListBox1.ClearSelected()
For i = 0 To my_list.Count - 1 ' add the records from the list to the listboxfrmPatient.xCheckedListBox1.Items.Add(my_list(i))
Next ' get the correct listmy_list = GetList2(show_who)
' clear out the bottom list boxfrmPatient.xCheckedListBox1.Items.Clear()
For i = 0 To my_list.Count - 1 ' add the records from the list to the listboxfrmPatient.xPlacedListBox.Items.Add(my_list(i))
Next End Sub Public Sub MoveToPlaced(ByVal index As Integer) ' This sub moves records from the top list box to the bottom ' list box when the Placedbutton is clicked. It does this by ' determining who is selected and which record in the top list ' box is selected. With this information, it can get the correct ' list and add the record to the bottom list box and to the ' appropriate list that holds Placed records for the resource. ' An index value of the selected record to move is passed from ' calling function or sub. Dim change_who As Integer Dim top_list As New List(Of String) Dim bottom_list As New List(Of String) Dim Update As String ' determine which resource is selectedchange_who = frmPatient.xCheckedListBox1.SelectedIndex
' get the correct list for the top listboxtop_list = GetList(change_who)
' get the correct list for the bottom listboxbottom_list = GetList2(change_who)
' get the correct record from the top listboxUpdate = top_list(index)
' remove the record from the top listtop_list.RemoveAt(index)
' add the record to the correct list that holds Placed records.AppendRecord2(change_who, TimeString.PadRight(13) & Update)
' now just show the correct records for the lists.ShowRecords()
End SubEnd
ModuleI see you have some VB6 or lower background. Lots of old school techniques..... Great commenting....
Your loading the CLB from the one of the arrays
XYG2, AWS, JBY after a click on the control. (I cann't find where you are loading the CLB at load.) I quickly scan the code so I could have missed it.
If I just missed the load procedure then run your app and check the arrays to see if your convertion from data set to array is correct.
When debuging does the arrays have data
As I could not find the CLB in form load I don't know witch array or dataset your starting with... If thier isn't some thing I'm missing the CLB doesn't load data until some data in it is click so it will never show anything...
Sorry for the quick scan if I did miss where your loading the CDL when the form opens or user does some thing then please post just it and i'll see if I can help more.
Yep VB6. the instructor i had in college has done VB for a long time.
lets start over. I at this moment just trying to get a checkedlistbox to fill from a database table I know the value i want if checked but can not see check boxes or names. when i do a preview of the data that is binded it shows the table. where do i need to go from there.
Sorry for starting over I just want to understand this control.
Without knowing what you are binding to I can only give you the basics.
Assuming a data set. Easiest way just set the CLB.datamember = Field name and CLB.datasource = yourdataset. Remember when you get the object back it will be in dataviewrow type(selection change etc). If you already to that point let me know....
If you are using a array to load the data, your going to have to load the data manully.. if this is the case let me know and i'll post a example or different techniqes to use.
the table name that has the list data
sorry but the above post will not work with .net 1 or 2. it required 3 or custom control.
Sorry about that. Here are two opptions.
1. Create a custom user control with databound objects. The link details the steps for a list box but it works the same for checkedlistbox.
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VSADD.v10.en/dnadvnet/html/vbnet08262002.htm Create a custom user control with databound objects.
or
2. Load data manully and keep track of the index. The example below used a type dataset using the employee table of the northwind DB. One CheckedListBox and one listbox with a single button.
Private col As New Generic.List(Of MyDataObject) ' Using a type collection I can easily keep track of the User ID or my row index. 'Load collection IN the form load or event you want.... **********************************Me
.CheckedListBox1.BeginUpdate() For Each dr As NorthwindDataSet.EmployeesRow In Me.NorthwindDataSet.Employeescol.Add(
New MyDataObject(dr.EmployeeID, dr.FirstName, dr.LastName)) 'Create a new object of MydataType with data.... Me.CheckedListBox1.Items.Add(dr.FirstName & " " & dr.LastName) ' Loads the check box. NextMe.CheckedListBox1.EndUpdate()
**************************************************************************************************************************************************************************
Private
Sub ShowResultsInListbox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickMe
.ListBox1.Items.Clear()For Each x As Integer In Me.CheckedListBox1.CheckedIndices
Me.ListBox1.Items.Add(col.Item(x).EmplyoyeeID & " " & col.Item(x).LastName) NextEnd Sub
''''''''''''''''''''''''''''''''''''''''' Type collection details ''''''''''''''''''****************************************************************************************************************************************
Public
Class MyDataObject Private _EmployeeID As Integer Private _FirstName As String Private _LastName As String Private Shared Counter As Integer Public Sub New() End Sub Public Sub New(ByVal eID As Integer, ByVal eFirstName As String, ByVal eLastName As String)EmplyoyeeID = eID
FirstName = eFirstName
LastName = eLastName
End Sub Public Property EmplyoyeeID() As Integer Get Return _EmployeeID End Get Set(ByVal value As Integer)_EmployeeID = value
End Set End Property Public Property FirstName() As String Get Return _FirstName End Get Set(ByVal value As String)_FirstName = value
End Set End Property Public Property LastName() As String Get Return _LastName End Get Set(ByVal value As String)_LastName = value
End Set End Property
End
ClassCyberTaz,
I am going to try thesse out. I will get back to you to say if i got working or not.
Thanks
I want to thank for you help cybertaz. but i got the answer but trudging along. here is what is did.
rivate
Sub frmPatient_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'TODO: This line of code loads data into the 'Ntier_SCOADataSet.Resources' table. You can move, or remove it, as needed. Me.xResourceT.Fill(Me.Ntier_SCOADataSet.Resources) 'This is used populate the checklistbox Dim items As String Dim r As Integer = 0 Dim c As Integer = 1 While r < xResourceT.GetData.Rows.Countitems =
CStr(xResourceT.GetData.Rows(r).Item(c))xCLBResource.Items.Add(items)
r = r + 1
End WhileHere is the code using your typed dataset. But thier is a issue down the road using either code. You just have the string and not a data index to link too.
Me.xResourceT.Fill(Me.Ntier_SCOADataSet.Resources)
for each dr as Resourcesrow in Me.Ntier_SCOADataSet.Resources
xCLBResource.Items.Add(dr.Myfieldname.tostring)
end for
GL
ok, that i understand and i am working on it, there will be a second variable as the index.
thank you once again