Click here to Skip to main content
15,921,622 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionappend menustrip items Pin
ivo755-Nov-09 7:51
ivo755-Nov-09 7:51 
AnswerRe: append menustrip items Pin
Christian Graus5-Nov-09 11:04
protectorChristian Graus5-Nov-09 11:04 
AnswerRe: append menustrip items Pin
The Man from U.N.C.L.E.5-Nov-09 22:54
The Man from U.N.C.L.E.5-Nov-09 22:54 
Question0.2+0.1<>0.3 in For Pin
The real $M@5-Nov-09 7:14
The real $M@5-Nov-09 7:14 
AnswerRe: 0.2+0.1<>0.3 in For Pin
Gideon Engelberth5-Nov-09 7:37
Gideon Engelberth5-Nov-09 7:37 
AnswerRe: 0.2+0.1<>0.3 in For Pin
Ian Shlasko5-Nov-09 7:50
Ian Shlasko5-Nov-09 7:50 
GeneralRe: 0.2+0.1<>0.3 in For Pin
The real $M@6-Nov-09 8:35
The real $M@6-Nov-09 8:35 
Questiondatadase binding to a check box Pin
rbjanaki5-Nov-09 3:48
rbjanaki5-Nov-09 3:48 
On the room form,include a combo box taht holds the room name. use check boxes to indicate if the room has a jacuzzi, private access, or fireplace. display the bed type and the room rates from the beds table

How to bind the checked property of a check box to a boolean data field

data looks like this

beds table

Doubles D 79.95 69.95
King K 105 95
Queen Q 95 85

rooms table
Forest K False False True
Garden K True True False
Library Q False True False
Ocean K False True True
Sun Room D False False False

so far I have this

'data tier

Imports System.Data

Public Class RoomsDataTier

    ' Module-level variables.
    Private ARoomTableAdapter _
      As CottagesDataSetTableAdapters.RoomsTableAdapter
    Private ABedsTableAdapter _
      As CottagesDataSetTableAdapters.BedsTableAdapter
    Private ACottagesDataSet As CottagesDataSet

    Public Sub New()
        Try
            ' Instantiate the TableAdapters and DataSet.
            ABedsTableAdapter = New  _
              CottagesDataSetTableAdapters.BedsTableAdapter()
            ARoomTableAdapter = New  _
              CottagesDataSetTableAdapters.RoomsTableAdapter()
            ACottagesDataSet = New CottagesDataSet
            ' Fill the DataSet.
            ARoomTableAdapter.Fill(ACottagesDataSet.Rooms)
            ABedsTableAdapter.Fill(ACottagesDataSet.Beds)
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Public Function GetDataSet() As CottagesDataSet
        ' Return the DataSet.

        Return ACottagesDataSet
    End Function
End Class

Imports System.Data
Public Class Rooms

    ' Module-level variables.
    Private AroomsDataTier As RoomsDataTier
    Private AcottagesDataSet As CottagesDataSet
    Private RoomsBindingSource As BindingSource
    Private BedsBindingSource As BindingSource

    Private Sub StoreForm_Load(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles MyBase.Load
        ' Set up the data for the combo box and text boxes.

        Try
            AroomsDataTier = New RoomsDataTier
            AcottagesDataSet = AroomsDataTier.GetDataSet

            ' Set up stores binding source.
            RoomsBindingSource = New BindingSource
            With RoomsBindingSource
                .DataSource = AcottagesDataSet
                .DataMember = "Rooms"
                .Sort = "Room"
            End With

            ' Bind the form controls.
            With RoomComboBox()
                .DataSource = RoomsBindingSource
                .DisplayMember = "Room"
                .ValueMember = "BedCode"
                .DataBindings.Add("text", RoomsBindingSource, _
                  "Room", False, DataSourceUpdateMode.Never)
                .SelectedIndex = -1
            End With
           
          
            ' Set up the  binding source.
            BedsBindingSource = New BindingSource
            With BedsBindingSource
                .DataSource = AcottagesDataSet
                .DataMember = "Beds"
            End With
        Catch ex As Exception
            MessageBox.Show("Error: " & ex.Message)
        End Try
    End Sub

    

    Private Sub RoomNameComboBox_SelectionChangeCommitted( _
      ByVal sender As Object, ByVal e As System.EventArgs) _
      Handles RoomComboBox.SelectionChangeCommitted
        ' Retrieve the sales information for the grid.
        Dim RoomsString As String
        Static GridInitializedBoolean As Boolean

        ' Retrieve the ID of the selected store.
        RoomsString = RoomComboBox.SelectedValue.ToString
        RoomCheckBox1.DataBindings.Add("CheckState", RoomsBindingSource, "MyColumn", False, DataSourceUpdateMode.OnPropertyChanged, DBNull.Value)
        ' Initialize the grid's binding.
        If Not GridInitializedBoolean Then
            ' Bind and format the grid.
            DataGridView1.DataSource = BedsBindingSource

            GridInitializedBoolean = True
        End If

        ' Filter the grid's data.
        BedsBindingSource.Filter = "BedCode = '" & RoomsString & "'"
    End Sub
end class


I am getting a runtime error saying that

Cannot bind to the property or column MyColumn on the DataSource. Parameter name: dataMember
AnswerRe: datadase binding to a check box Pin
Jay Royall5-Nov-09 4:09
Jay Royall5-Nov-09 4:09 
GeneralRe: datadase binding to a check box Pin
rbjanaki5-Nov-09 5:43
rbjanaki5-Nov-09 5:43 
GeneralRe: datadase binding to a check box Pin
Jay Royall5-Nov-09 5:51
Jay Royall5-Nov-09 5:51 
GeneralRe: datadase binding to a check box Pin
rbjanaki5-Nov-09 6:25
rbjanaki5-Nov-09 6:25 
GeneralRe: datadase binding to a check box Pin
rbjanaki5-Nov-09 6:27
rbjanaki5-Nov-09 6:27 
GeneralRe: datadase binding to a check box Pin
Jay Royall5-Nov-09 10:32
Jay Royall5-Nov-09 10:32 
QuestionHow to use Transparency key in Splash Screen Pin
Ovais Memon5-Nov-09 0:18
Ovais Memon5-Nov-09 0:18 
AnswerRe: How to use Transparency key in Splash Screen Pin
John M Bundy5-Nov-09 2:35
John M Bundy5-Nov-09 2:35 
AnswerRe: How to use Transparency key in Splash Screen Pin
Steven J Jowett5-Nov-09 5:10
Steven J Jowett5-Nov-09 5:10 
AnswerRe: How to use Transparency key in Splash Screen Pin
The Man from U.N.C.L.E.5-Nov-09 6:33
The Man from U.N.C.L.E.5-Nov-09 6:33 
AnswerRe: How to use Transparency key in Splash Screen Pin
Christian Graus5-Nov-09 10:45
protectorChristian Graus5-Nov-09 10:45 
QuestionCreate Chart in Xtrareport Pin
faravani4-Nov-09 23:22
faravani4-Nov-09 23:22 
AnswerRe: Create Chart in Xtrareport Pin
Fabio V Silva4-Nov-09 23:37
Fabio V Silva4-Nov-09 23:37 
AnswerRe: Create Chart in Xtrareport Pin
Dave Kreskowiak5-Nov-09 4:24
mveDave Kreskowiak5-Nov-09 4:24 
QuestionMissing Caption in Application Pin
mdrizwan_14-Nov-09 22:01
mdrizwan_14-Nov-09 22:01 
AnswerRe: Missing Caption in Application Pin
Mycroft Holmes4-Nov-09 22:13
professionalMycroft Holmes4-Nov-09 22:13 
GeneralRe: Missing Caption in Application Pin
mdrizwan_14-Nov-09 22:26
mdrizwan_14-Nov-09 22:26 

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.