Click here to Skip to main content
15,917,642 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Error binding picture box? Pin
Dave Kreskowiak17-Jun-04 3:46
mveDave Kreskowiak17-Jun-04 3:46 
GeneralRe: Error binding picture box? Pin
mythinky17-Jun-04 21:57
mythinky17-Jun-04 21:57 
GeneralRe: Error binding picture box? Pin
Dave Kreskowiak18-Jun-04 10:27
mveDave Kreskowiak18-Jun-04 10:27 
GeneralRe: Error binding picture box? Pin
mythinky23-Jun-04 17:59
mythinky23-Jun-04 17:59 
GeneralRe: Error binding picture box? Pin
Dave Kreskowiak24-Jun-04 2:52
mveDave Kreskowiak24-Jun-04 2:52 
GeneralRe: Error binding picture box? Pin
mythinky24-Jun-04 18:42
mythinky24-Jun-04 18:42 
GeneralRe: Error binding picture box? Pin
Dave Kreskowiak25-Jun-04 1:20
mveDave Kreskowiak25-Jun-04 1:20 
GeneralRe: Error binding picture box? Pin
mythinky28-Jun-04 15:45
mythinky28-Jun-04 15:45 
This is part of the frmBookDetails class.
<background color="yellow">
Imports System.Data
Imports System.Data.OleDb
Imports System.DBNull
Imports System.IO
Imports System.Drawing

Public Class frmBookDetails
Inherits System.Windows.Forms.Form

Dim objConLib As OleDbConnection = New OleDbConnection(sConnectDBLib)
Dim objDAdp As OleDbDataAdapter
Dim objDSet As DataSet
Dim objDView As DataView
Dim objCMngr As CurrencyManager

Dim objDataAdp As OleDbDataAdapter
Dim objDataSet As DataSet

Dim response As MsgBoxResult
Dim isValidPath, isNeedToClose As Boolean
Dim isValidBookTitle, isValidBookAuthor, isValidPublisher, isValidYearPublished As Boolean
Dim isValidEdition, isValidCourseBook As Boolean

Dim isBookIDChanged, isBookTitleChanged, isBookAuthorChanged, isPublisherChanged, isYearPublishedChanged As Boolean
Dim isEditionChanged, isCourseBookChanged, isCategoryChanged As Boolean

Windows Form Designer Generated Code

Private Sub FillDataSetAndView()
Try
objDView = Nothing
objDSet = New DataSet()
objConLib.Open()
objDAdp = New OleDbDataAdapter()
objDAdp.SelectCommand = New OleDbCommand("[GETBOOKDETAILS]", objConLib)
objDAdp.SelectCommand.CommandType = CommandType.StoredProcedure
objDAdp.Fill(objDSet, "BOOKDETAILS")
objDView = New DataView(objDSet.Tables("BOOKDETAILS"))
objCMngr = CType(Me.BindingContext(objDView), CurrencyManager)
objCMngr.Position = objCMngr.Count - 1

objDataAdp = New OleDbDataAdapter()
objDataAdp.SelectCommand = New OleDbCommand("SELECT * FROM BOOKCATEGORY", objConLib)
objDataAdp.SelectCommand.CommandType = CommandType.Text

objConLib.Close()
objDSet = Nothing

Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "FillDataSetAndView")
End Try
End Sub

Private Sub ClearBindFields()
txtBookID.DataBindings.Clear()
txtBookTitle.DataBindings.Clear()
txtBookAuthor.DataBindings.Clear()
txtCategory.DataBindings.Clear()
txtPublisher.DataBindings.Clear()
txtYearPublished.DataBindings.Clear()
txtEdition.DataBindings.Clear()
txtCourseBook.DataBindings.Clear()
txtOriginalOwned.DataBindings.Clear()
txtCopiesOwned.DataBindings.Clear()
txtCopiesLoan.DataBindings.Clear()
txtCopiesShelves.DataBindings.Clear()
txtCopiesSold.DataBindings.Clear()
picBook.DataBindings.Clear()
End Sub

Private Sub BindFields()
Try
txtBookID.DataBindings.Add("Text", objDView, "BookID")
txtBookTitle.DataBindings.Add("Text", objDView, "Title")
txtBookAuthor.DataBindings.Add("Text", objDView, "Author")
txtCategory.DataBindings.Add("Text", objDView, "Category")
'cmbCategory.DataBindings.Add("Text", objDView, "Category")
txtPublisher.DataBindings.Add("Text", objDView, "Publisher")
txtYearPublished.DataBindings.Add("Text", objDView, "YearLastPub")
txtEdition.DataBindings.Add("Text", objDView, "Edition")
txtCourseBook.DataBindings.Add("Text", objDView, "CourseBook")
txtOriginalOwned.DataBindings.Add("Text", objDView, "NoOriginalOwned")
txtCopiesOwned.DataBindings.Add("Text", objDView, "NoCopyOwned")
txtCopiesLoan.DataBindings.Add("Text", objDView, "NoCopyonLoan")
txtCopiesShelves.DataBindings.Add("Text", objDView, "NoCopyInShelves")
txtCopiesSold.DataBindings.Add("Text", objDView, "NoCopySoldorLost")

'Dim b As Binding = New Binding("Image", objDView, "CoverSample")
'AddHandler b.Format, AddressOf MyPictureBox_FormatImage
'picBook.DataBindings.Add(b)
Catch ex As InvalidCastException
MsgBox(ex.Message, , "BindFields")
End Try
End Sub

Private Sub MyPictureBox_FormatImage(ByVal sender As Object, ByVal e As ConvertEventArgs)
Try
' Check to see if this is a valid conversion.
If Not e.DesiredType Is GetType(Image) Then
MsgBox("FormatImage was called with the DesiredType of " & _
e.DesiredType.ToString, , "MyPictureBox_FormatImage")
Exit Sub
End If
' Check if the file exists (assumes "Imports System.IO").
' Uses the Static version of the Exists method.
Try
If Not File.Exists(e.Value.ToString) Then
MsgBox("File not found: " & e.Value.ToString, , "MyPictureBox_FormatImage")
Exit Sub
Else
' The file exists, try to create an Image object out of it.
e.Value = Image.FromFile(e.Value.ToString)
End If
Catch
End Try
Catch ex As Exception
MsgBox(ex.Message, , "MyPictureBox_FormatImage")
End Try
End Sub



Learning .NET
GeneralRe: Error binding picture box? Pin
Dave Kreskowiak28-Jun-04 17:05
mveDave Kreskowiak28-Jun-04 17:05 
GeneralRe: Error binding picture box? Pin
mythinky28-Jun-04 17:21
mythinky28-Jun-04 17:21 
GeneralRe: Error binding picture box? Pin
Dave Kreskowiak29-Jun-04 1:04
mveDave Kreskowiak29-Jun-04 1:04 
GeneralRe: Error binding picture box? Pin
mythinky30-Jun-04 15:31
mythinky30-Jun-04 15:31 
GeneralRe: Error binding picture box? Pin
Dave Kreskowiak1-Jul-04 1:32
mveDave Kreskowiak1-Jul-04 1:32 
GeneralRe: Error binding picture box? Pin
mythinky5-Jul-04 15:26
mythinky5-Jul-04 15:26 
GeneralRe: Error binding picture box? Pin
Dave Kreskowiak6-Jul-04 23:49
mveDave Kreskowiak6-Jul-04 23:49 
GeneralRe: Error binding picture box? Pin
mythinky11-Jul-04 23:04
mythinky11-Jul-04 23:04 
QuestionError send email? Pin
mythinky16-Jun-04 16:03
mythinky16-Jun-04 16:03 
AnswerRe: Error send email? Pin
Dave Kreskowiak17-Jun-04 3:24
mveDave Kreskowiak17-Jun-04 3:24 
GeneralRe: Error send email? Pin
mythinky17-Jun-04 22:02
mythinky17-Jun-04 22:02 
AnswerRe: Error send email? Pin
Aaron Eldreth17-Jun-04 4:16
Aaron Eldreth17-Jun-04 4:16 
Generalput icon Context Menu on File selection Pin
skoizumi2911016-Jun-04 12:59
sussskoizumi2911016-Jun-04 12:59 
GeneralRe: put icon Context Menu on File selection Pin
tramdtt16-Jun-04 14:38
tramdtt16-Jun-04 14:38 
GeneralRe: put icon Context Menu on File selection Pin
vancouver77716-Jun-04 14:40
vancouver77716-Jun-04 14:40 
GeneralRe: put icon Context Menu on File selection Pin
tramdtt16-Jun-04 15:55
tramdtt16-Jun-04 15:55 
GeneralRe: put icon Context Menu on File selection Pin
shinay16-Jun-04 19:22
shinay16-Jun-04 19:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.