|
-
Jul 28th, 2007, 09:51 AM
#1
Thread Starter
Hyperactive Member
[2005] Search and textboxes
I have a form and im planning on putting a search textbox wherein once i input the ID number of the employee, all the textboxes in the form that displays the information of the employee will also change, so far i can only do this through move next , move first , move last, move previous buttons.
-
Jul 28th, 2007, 10:47 AM
#2
Re: [2005] Search and textboxes
-
Jul 28th, 2007, 11:00 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Search and textboxes
i need to know the codes on how to make a textbox display the corresponding records in the form..
so the searchtextbox is where i will put an employee number and then all the other textboxes with employee recordss.. (employee name, emplyoee tel..) will also change to the data corresponding to the employeeID number
-
Jul 28th, 2007, 11:15 AM
#4
Re: [2005] Search and textboxes
 Originally Posted by aerialz666
i need to know the codes on how to make a textbox display the corresponding records in the form..
so the searchtextbox is where i will put an employee number and then all the other textboxes with employee recordss.. (employee name, emplyoee tel..) will also change to the data corresponding to the employeeID number
Hi,
Can't you use a Auto-Complete combobox and if the ID is found put all the records into your textBoxes.
Wkr,
sparrow1
-
Jul 28th, 2007, 12:03 PM
#5
Thread Starter
Hyperactive Member
Re: [2005] Search and textboxes
Hi can you teach me how to do it sparrow? what to put on auto complete and a sample of moving the records corresponding to the ID number
-
Jul 28th, 2007, 01:12 PM
#6
Re: [2005] Search and textboxes
 Originally Posted by aerialz666
Hi can you teach me how to do it sparrow? what to put on auto complete and a sample of moving the records corresponding to the ID number
Hi,
Here's an exmple how to use a auto-complete combobox.
I'll have to tell you that I made this with a TextBox.
Code:
Private ControlKey As Boolean = False
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("Zebra")
ComboBox1.Items.Add("Monkey")
ComboBox1.Items.Add("Fly")
ComboBox1.Items.Add("Spider")
ComboBox1.Items.Add("Crocodil")
ComboBox1.Items.Add("Tiger")
ComboBox1.Items.Add("Lion")
ComboBox1.Items.Add("Airplane")
ComboBox1.Items.Add("Boot")
ComboBox1.Items.Add("Sea cow")
End Sub
Private Sub ComboBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
Dim Combo As ComboBox = CType(sender, ComboBox)
If Combo.Text <> "" And Not ControlKey Then
Dim MatchText As String = Combo.Text
Dim Match As Integer = Combo.FindString(MatchText)
If Match <> -1 Then
Combo.SelectedIndex = Match
Combo.SelectionStart = MatchText.Length
Combo.SelectionLength = Combo.Text.Length - Combo.SelectionStart
TextBox1.Text = ComboBox1.Text
If ComboBox1.SelectedIndex Then
TextBox1.Text = ComboBox1.Text
End If
End If
End If
End Sub
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
Dim Combo As ComboBox = CType(sender, ComboBox)
If Asc(e.KeyChar) = Keys.Escape Then
Combo.SelectedIndex = -1
Combo.Text = ""
ControlKey = True
ElseIf Char.IsControl(e.KeyChar) Then
ControlKey = True
Else
ControlKey = False
End If
End Sub
Hope it will guide you into the proper direction.
Wkr,
sparrow1
-
Jul 28th, 2007, 02:07 PM
#7
Thread Starter
Hyperactive Member
Re: [2005] Search and textboxes
thanks, i tried a select statement in the combobox and its now working, the problem is that, the department names listed is repeating ex.
here are the items in the CBO
CA
HRM
IT
CA
HRM
IT
CA
HRM
IT
--
i only have 3 different departments, but in the combobox at run time it shows multiple items that are the same as the original 3. what should i add or do so that there will be no duplicate items shown in the cbo thanks
-
Jul 28th, 2007, 02:13 PM
#8
Re: [2005] Search and textboxes
Hi,
How do you add the items into your combobox?
Wkr,
sparrow1
-
Jul 28th, 2007, 02:14 PM
#9
Thread Starter
Hyperactive Member
Re: [2005] Search and textboxes
well i call an SQL statement.. Select DepartmentName from DepartmentList
-
Jul 28th, 2007, 02:30 PM
#10
Re: [2005] Search and textboxes
 Originally Posted by aerialz666
well i call an SQL statement.. Select DepartmentName from DepartmentList
Hi,
Here's previous thread about diplication in a combobox.
http://www.vbforums.com/showthread.p...items+combobox
Hope it helps,
sparrow1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|