Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Database > Database General Discussion

Database General Discussion General discussion on database related topics

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2009, 12:06 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Age: 24
Posts: 2
Reputation: 0
LoGaN-ES is on a distinguished programming path ahead
Post Selecting only one fieldin ListView

Hi!

I am a bit a newbie in VB.NET, and I am trying to make some sort of product catalog
which will pull data from Access database.The data is displayed in ListView, and I have
2 problems.

1.The following code is for display data text for each selected row from ListView(which is in details):
------------------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub ListView1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick

Try
Dim str As String
Dim j As Byte
str = ListView1.Columns(0).Text & " ..." & ListView1.SelectedItems(0).Text
For j = 1 To ListView1.Columns.Count - 1
str = str & ListView1.Columns(j).Text & " ... " & ListView1.SelectedItems(0).SubItems(j).Text
Next

TextBox1.Text = str

Catch exp As Exception

End Try
-----------------------------------------------------------------------------------------------------------------------------------------------------------
I am displayed all data as text from whole row, but I want only to display data from one field in row that is selected.

2.I have in my database a picture for a each row as OLE object, and I want do display that picture in PictureBox for a item that is
selected in ListView.I am using a OleDbConnection to populate ListView from database:
-------------------------------------------------------------------------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
oledbcon.Open()
strSQL = "SELECT * FROM MaticnePloce"
cmd = New OleDbCommand(strSQL, oledbcon)
objRead = cmd.ExecuteReader
While objRead.Read
lv = Me.ListView1.Items.Add(objRead("SifraArtikla") & (""))
lv.SubItems.Add(objRead("NazivArtikla") & "")
lv.SubItems.Add(objRead("JM") & "")
End While

objRead.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
oledbcon.Close()
End Try


End Sub
-------------------------------------------------------------------------------------------------------------------------------
Any suggestion I will appriciate.Greetz!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-06-2009, 12:58 AM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,006
Reputation: 538
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

Quote:
I am displayed all data as text from whole row, but I want only to display data from one field in row that is selected.
Only get the Text of the desired subitem instead of all the subitems.
Quote:
I have in my database a picture for a each row as OLE object, and I want do display that picture in PictureBox for a item that is
selected in ListView.
Create an Image object for each row and assign it to the Tag property of the corresponding ListViewItem. In the SelectedIndexChanged event handler you can get the Image and display it in the PictureBox. [ame="http://www.vbforums.com/showthread.php?t=469562"]Here[/ame] is an example of getting Images from a database.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 11:28 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.