Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 19th, 2011, 03:16 AM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default list view to text boxes!!

do you know that code for every time i click the list box it will automatically go to the text box?? for example i click the first index and all of the information will automatically go to textboxes here is my code i think i have mistaken something here bcz evertime i click the index of the list view its not updating the textbox. .
any suggestions?


__________________________________________________ _______________
Public Class Form1
Inherits System.Windows.Forms.Form
Dim nCon As New SqlClient.SqlConnection
Dim nCommand As New SqlClient.SqlCommand
Dim nReader As SqlClient.SqlDataReader
Private Sub connect()
On Error Resume Next
nCon.ConnectionString = "workstation id=BEGS-LAPTOP;packet size=4096;integrated security=SSPI;data source=BEGS-LAPTOP;persist security info=False;initial catalog=DB_INTRANET_HRIS"
nCommand.Connection = nCon
nCon.Open()
End Sub
Private Sub filllvwStudentColumnHeaders()
' add a column width 140 and left alignment
lvwStudent.Columns.Add("User ID", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("Lastname", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("Firstname", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("Middle Initial", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("User Level", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("User Name", 140, HorizontalAlignment.Left)
lvwStudent.Columns.Add("Password", 140, HorizontalAlignment.Left)
End Sub

Private Sub FilllvwStudent()


Call connect()
nCommand.CommandText = "SELECT * FROM tb_user"
nCommand.Connection = nCon
nReader = nCommand.ExecuteReader()
lvwStudent.Items.Clear()

While (nReader.Read())
With lvwStudent.Items.Add(nReader("User_id"))
.SubItems.add(nReader.GetValue(1))
.subitems.add(nReader.GetValue(2))
.subitems.add(nReader.GetValue(3))
.subitems.add(nReader.GetValue(4))
.subitems.add(nReader.GetValue(5))
.subitems.add(nReader.GetValue(6))
End With
End While
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If nCon.State = ConnectionState.Open Then nCon.Close()
nCon.ConnectionString = "workstation id=BEGS-LAPTOP;packet size=4096;integrated security=SSPI;data source=BEGS-LAPTOP;persist security info=False;initial catalog=DB_INTRANET_HRIS"
nCommand.Connection = nCon
Call connect()

lvwStudent.MultiSelect = False
lvwStudent.GridLines = True
lvwStudent.View = View.Details

Call filllvwStudentColumnHeaders()
Call FilllvwStudent()
lvwStudent.Items(0).Selected = True

Call PutToTextboxes()
End Sub
Private Sub PutToTextboxes()
TextBox1.Text = lvwStudent.SelectedItems(0).Text
TextBox2.Text = lvwStudent.SelectedItems(0).SubItems(1).Text
TextBox3.Text = lvwStudent.SelectedItems(0).SubItems(2).Text
TextBox4.Text = lvwStudent.SelectedItems(0).SubItems(3).Text
TextBox5.Text = lvwStudent.SelectedItems(0).SubItems(4).Text
TextBox6.Text = lvwStudent.SelectedItems(0).SubItems(5).Text
TextBox7.Text = lvwStudent.SelectedItems(0).SubItems(6).Tex
End Sub
End Class
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with List Boxes Jewel142 BOOK: Visual Basic 2010 Programmer's Reference 4 April 5th, 2011 08:43 AM
Displaying data in a tree view from combo boxes Gini Visual Studio 2008 0 June 25th, 2008 01:52 AM
Help Grid View Drop Down List, view all jskinner123 ASP.NET 2.0 Basics 0 November 25th, 2007 05:25 PM
populate details view or list view non empty rows iinfoque ASP.NET 2.0 Basics 0 March 11th, 2007 06:11 AM
SQL , List Boxes/Menu Boxes, DB's Ginzu3 Classic ASP Databases 1 June 30th, 2003 04:07 AM



All times are GMT -4. The time now is 11:04 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.