By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,838 Members | 1,606 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,838 IT Pros & Developers. It's quick & easy.

ComboBox databindng Problem

P: n/a
ComboBox databindng Problem

== How the ComboBox is setup and used:

My comboBox is populated by a lookup table. The ValueMember is the
lookup table's Id and the DisplayMember is the text from a
corresponding field in the lookup table. In my data table we store the
ID in what I will call the 'key' field.

== Description of the desired operation:

1.) When the user selects a record in the datagrid the bound comboBox
displays the DisplayMember of the corresponding Value stored in the
data table's 'key' field.
2.) When the user selects a record in where the 'key' field is null (no
selection was made or saved) the comboBox display should be empty to
indicated that fact.

== Description of the problem:

Simply put, #2 above does not happen. Here is what does; When the user
moves to a record in the datagrid in which the 'key' field is null the
comboBox is *not* empty, it incorrectly displays the first possible
selection in the comboBox.

== Additional facts: (read carefully - this could be a little
confusing)

Consider a scenario in which the 1st record stores a value in the 'key'
field and in the 2nd and 3rd records in which the 'key' field is null.
Here is what happens when we walk through the records;
In the 1st record: the comboBox always displays the correct value
corresponding to the 'key' field.
As the user moves to the 2nd record: incorrectly - values are shown
rather than being empty.
As the user moves to the 3rd record: correctly - the comboBox is shown
empty.
As the user moves back to the 2nd record: correctly - the comboBox is
shown empty this time.

In summary - when you move from a record with a populated 'key' to a
record with a null 'key' field - incorrect values will *always* be
displayed. When you move from record with a null 'key' field to another
record with a null 'key' field - correctly a *blank* will *always* be
displayed in the comboBox. Records with a populated 'key' filed will
*always display correct values.

What is the reason for the wrong display behavior?
What is the solution to get proper display behavior?

========================
BTW - Here is the order in which I populate and bind the controls and
datagrid.
1.) populate the dataset with the datatables for the datagrid, controls
and the combobox
2.) set the combobox datasource, value and display members
3.) set the datagrid datasource and datamember
4.) bind the controls to the datatable and corresponding field
5.) set the binding context to the datatable

Nov 21 '05 #1
Share this Question
Share on Google+
30 Replies


P: n/a
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
ComboBox databindng Problem

== How the ComboBox is setup and used:

My comboBox is populated by a lookup table. The ValueMember is the
lookup table's Id and the DisplayMember is the text from a
corresponding field in the lookup table. In my data table we store the
ID in what I will call the 'key' field.

== Description of the desired operation:

1.) When the user selects a record in the datagrid the bound comboBox
displays the DisplayMember of the corresponding Value stored in the
data table's 'key' field.
2.) When the user selects a record in where the 'key' field is null (no
selection was made or saved) the comboBox display should be empty to
indicated that fact.

== Description of the problem:

Simply put, #2 above does not happen. Here is what does; When the user
moves to a record in the datagrid in which the 'key' field is null the
comboBox is *not* empty, it incorrectly displays the first possible
selection in the comboBox.

== Additional facts: (read carefully - this could be a little
confusing)

Consider a scenario in which the 1st record stores a value in the 'key'
field and in the 2nd and 3rd records in which the 'key' field is null.
Here is what happens when we walk through the records;
In the 1st record: the comboBox always displays the correct value
corresponding to the 'key' field.
As the user moves to the 2nd record: incorrectly - values are shown
rather than being empty.
As the user moves to the 3rd record: correctly - the comboBox is shown
empty.
As the user moves back to the 2nd record: correctly - the comboBox is
shown empty this time.

In summary - when you move from a record with a populated 'key' to a
record with a null 'key' field - incorrect values will *always* be
displayed. When you move from record with a null 'key' field to another
record with a null 'key' field - correctly a *blank* will *always* be
displayed in the comboBox. Records with a populated 'key' filed will
*always display correct values.

What is the reason for the wrong display behavior?
What is the solution to get proper display behavior?

========================
BTW - Here is the order in which I populate and bind the controls and
datagrid.
1.) populate the dataset with the datatables for the datagrid, controls
and the combobox
2.) set the combobox datasource, value and display members
3.) set the datagrid datasource and datamember
4.) bind the controls to the datatable and corresponding field
5.) set the binding context to the datatable


Not sure what you mean in number 5.

Altough it seems that other people had a similar problem with null values
and lookup combo, i can not reproduce this problem. It works perfectly even
on the first null.

Maybe you could post the entire code that reproduces this problem ?
What version of framework are you using ?

hth,
greetings
Nov 21 '05 #2

P: n/a
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
ComboBox databindng Problem

== How the ComboBox is setup and used:

My comboBox is populated by a lookup table. The ValueMember is the
lookup table's Id and the DisplayMember is the text from a
corresponding field in the lookup table. In my data table we store the
ID in what I will call the 'key' field.

== Description of the desired operation:

1.) When the user selects a record in the datagrid the bound comboBox
displays the DisplayMember of the corresponding Value stored in the
data table's 'key' field.
2.) When the user selects a record in where the 'key' field is null (no
selection was made or saved) the comboBox display should be empty to
indicated that fact.

== Description of the problem:

Simply put, #2 above does not happen. Here is what does; When the user
moves to a record in the datagrid in which the 'key' field is null the
comboBox is *not* empty, it incorrectly displays the first possible
selection in the comboBox.

== Additional facts: (read carefully - this could be a little
confusing)

Consider a scenario in which the 1st record stores a value in the 'key'
field and in the 2nd and 3rd records in which the 'key' field is null.
Here is what happens when we walk through the records;
In the 1st record: the comboBox always displays the correct value
corresponding to the 'key' field.
As the user moves to the 2nd record: incorrectly - values are shown
rather than being empty.
As the user moves to the 3rd record: correctly - the comboBox is shown
empty.
As the user moves back to the 2nd record: correctly - the comboBox is
shown empty this time.

In summary - when you move from a record with a populated 'key' to a
record with a null 'key' field - incorrect values will *always* be
displayed. When you move from record with a null 'key' field to another
record with a null 'key' field - correctly a *blank* will *always* be
displayed in the comboBox. Records with a populated 'key' filed will
*always display correct values.

What is the reason for the wrong display behavior?
What is the solution to get proper display behavior?

========================
BTW - Here is the order in which I populate and bind the controls and
datagrid.
1.) populate the dataset with the datatables for the datagrid, controls
and the combobox
2.) set the combobox datasource, value and display members
3.) set the datagrid datasource and datamember
4.) bind the controls to the datatable and corresponding field
5.) set the binding context to the datatable


Not sure what you mean in number 5.

Altough it seems that other people had a similar problem with null values
and lookup combo, i can not reproduce this problem. It works perfectly even
on the first null.

Maybe you could post the entire code that reproduces this problem ?
What version of framework are you using ?

hth,
greetings
Nov 21 '05 #3

P: n/a
> Not sure what you mean in number 5.

Here is what I mean by number 5...
This variable is created;

Protected WithEvents _bmb As BindingManagerBase

Then just after the controls binding I do this;
_bmb = Me.BindingContext(_dt)
What version of framework are you using ? DotNet framework 1.1.4322 SP1
Visual Studio 2003 Version 7.1.3088
Maybe you could post the entire code that reproduces this problem ?

I'll try to do this within a day.

Nov 21 '05 #4

P: n/a
> Not sure what you mean in number 5.

Here is what I mean by number 5...
This variable is created;

Protected WithEvents _bmb As BindingManagerBase

Then just after the controls binding I do this;
_bmb = Me.BindingContext(_dt)
What version of framework are you using ? DotNet framework 1.1.4322 SP1
Visual Studio 2003 Version 7.1.3088
Maybe you could post the entire code that reproduces this problem ?

I'll try to do this within a day.

Nov 21 '05 #5

P: n/a
Hi Bart,
Maybe you could post the entire code that reproduces this problem ?


Here is the entire code necessary to reproduce the problem. (It is
simplified to contain only the code necessary)
1.) Form Code
2.) Data Tables (SQL)
3.) Sample Data
4.) Data set code
5.) Data access code
6.) Stored Procedures

======================
1.) Form Code
\\
Public Class f010Jobs
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents labUserNote As System.Windows.Forms.Label
Friend WithEvents txtJobDescription As System.Windows.Forms.TextBox
Friend WithEvents labJobDescription As System.Windows.Forms.Label
Friend WithEvents labCustomerName As System.Windows.Forms.Label
Friend WithEvents labJobNumber As System.Windows.Forms.Label
Friend WithEvents txtJobNumber As System.Windows.Forms.TextBox
Friend WithEvents txtUserNote As System.Windows.Forms.TextBox
Friend WithEvents grpSystemServices As System.Windows.Forms.GroupBox
Friend WithEvents txtShopPSI As System.Windows.Forms.TextBox
Friend WithEvents labShopPsi As System.Windows.Forms.Label
Friend WithEvents labSystemVoltage As System.Windows.Forms.Label
Friend WithEvents labSystemPhase As System.Windows.Forms.Label
Friend WithEvents labSystemAmps As System.Windows.Forms.Label
Friend WithEvents txtSystemAmps As System.Windows.Forms.TextBox
Friend WithEvents lblpkJobId As System.Windows.Forms.Label
Friend WithEvents labJobId As System.Windows.Forms.Label
Friend WithEvents cboSystemPhase As System.Windows.Forms.ComboBox
Friend WithEvents cboSystemVoltage As System.Windows.Forms.ComboBox
Friend WithEvents chkHasCircuitBreakersYN As
System.Windows.Forms.CheckBox
Friend WithEvents chkApprovedYN As System.Windows.Forms.CheckBox
Friend WithEvents chkCompletedYN As System.Windows.Forms.CheckBox
Friend WithEvents labReferenceJobNumber As System.Windows.Forms.Label
Friend WithEvents lblReferenceJobNumber As System.Windows.Forms.Label
Friend WithEvents chkIsMasterYN As System.Windows.Forms.CheckBox
Friend WithEvents chkAllProcessesAddedYN As
System.Windows.Forms.CheckBox
Friend WithEvents chkAllProcessesConfiguredYN As
System.Windows.Forms.CheckBox
Friend WithEvents chkArchive As System.Windows.Forms.CheckBox
Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
Friend WithEvents lblCountOfJobs As System.Windows.Forms.Label
Friend WithEvents labTotalJobs As System.Windows.Forms.Label
Friend WithEvents chkAllTasksAddedYN As System.Windows.Forms.CheckBox
Friend WithEvents MsdnTextboxValidator1 As
MSDNTextboxValidator.MSDNTextboxValidator
Friend WithEvents ErrorProvider1 As System.Windows.Forms.ErrorProvider
Friend WithEvents txtCustomerName As System.Windows.Forms.TextBox
Friend WithEvents lblCountOfConfigured As System.Windows.Forms.Label
Friend WithEvents labTotalConfigured As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
Protected WithEvents txtEditedBy As System.Windows.Forms.TextBox
Protected WithEvents txtEditedOn As System.Windows.Forms.TextBox
Protected WithEvents txtCreatedBy As System.Windows.Forms.TextBox
Protected WithEvents txtCreatedOn As System.Windows.Forms.TextBox
Protected WithEvents labEditedBy As System.Windows.Forms.Label
Protected WithEvents labEditedOn As System.Windows.Forms.Label
Protected WithEvents labCreatedBy As System.Windows.Forms.Label
Protected WithEvents labCreatedOn As System.Windows.Forms.Label
Public WithEvents DataGrid1 As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.lblpkJobId = New System.Windows.Forms.Label
Me.labJobId = New System.Windows.Forms.Label
Me.chkCompletedYN = New System.Windows.Forms.CheckBox
Me.chkApprovedYN = New System.Windows.Forms.CheckBox
Me.labUserNote = New System.Windows.Forms.Label
Me.labReferenceJobNumber = New System.Windows.Forms.Label
Me.txtJobDescription = New System.Windows.Forms.TextBox
Me.labJobDescription = New System.Windows.Forms.Label
Me.labCustomerName = New System.Windows.Forms.Label
Me.labJobNumber = New System.Windows.Forms.Label
Me.txtJobNumber = New System.Windows.Forms.TextBox
Me.txtUserNote = New System.Windows.Forms.TextBox
Me.grpSystemServices = New System.Windows.Forms.GroupBox
Me.chkHasCircuitBreakersYN = New System.Windows.Forms.CheckBox
Me.txtSystemAmps = New System.Windows.Forms.TextBox
Me.labSystemAmps = New System.Windows.Forms.Label
Me.cboSystemPhase = New System.Windows.Forms.ComboBox
Me.labSystemPhase = New System.Windows.Forms.Label
Me.cboSystemVoltage = New System.Windows.Forms.ComboBox
Me.labSystemVoltage = New System.Windows.Forms.Label
Me.txtShopPSI = New System.Windows.Forms.TextBox
Me.labShopPsi = New System.Windows.Forms.Label
Me.chkIsMasterYN = New System.Windows.Forms.CheckBox
Me.lblReferenceJobNumber = New System.Windows.Forms.Label
Me.chkAllProcessesAddedYN = New System.Windows.Forms.CheckBox
Me.chkAllProcessesConfiguredYN = New System.Windows.Forms.CheckBox
Me.chkArchive = New System.Windows.Forms.CheckBox
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.txtCustomerName = New System.Windows.Forms.TextBox
Me.lblCountOfJobs = New System.Windows.Forms.Label
Me.labTotalJobs = New System.Windows.Forms.Label
Me.chkAllTasksAddedYN = New System.Windows.Forms.CheckBox
Me.MsdnTextboxValidator1 = New
MSDNTextboxValidator.MSDNTextboxValidator(Me.compo nents)
Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider
Me.txtEditedBy = New System.Windows.Forms.TextBox
Me.txtEditedOn = New System.Windows.Forms.TextBox
Me.txtCreatedBy = New System.Windows.Forms.TextBox
Me.txtCreatedOn = New System.Windows.Forms.TextBox
Me.lblCountOfConfigured = New System.Windows.Forms.Label
Me.labTotalConfigured = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.btnExit = New System.Windows.Forms.Button
Me.labEditedBy = New System.Windows.Forms.Label
Me.labEditedOn = New System.Windows.Forms.Label
Me.labCreatedBy = New System.Windows.Forms.Label
Me.labCreatedOn = New System.Windows.Forms.Label
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.grpSystemServices.SuspendLayout()
CType(Me.DataGrid1,
System.ComponentModel.ISupportInitialize).BeginIni t()
Me.SuspendLayout()
'
'lblpkJobId
'
Me.lblpkJobId.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lblpkJobId.ForeColor = System.Drawing.SystemColors.GrayText
Me.lblpkJobId.Location = New System.Drawing.Point(120, 352)
Me.lblpkJobId.Name = "lblpkJobId"
Me.lblpkJobId.Size = New System.Drawing.Size(248, 23)
Me.lblpkJobId.TabIndex = 1
Me.lblpkJobId.Tag = ""
'
'labJobId
'
Me.labJobId.Location = New System.Drawing.Point(8, 352)
Me.labJobId.Name = "labJobId"
Me.labJobId.TabIndex = 0
Me.labJobId.Tag = ""
Me.labJobId.Text = "Job ID:"
'
'chkCompletedYN
'
Me.chkCompletedYN.Location = New System.Drawing.Point(744, 472)
Me.chkCompletedYN.Name = "chkCompletedYN"
Me.chkCompletedYN.Size = New System.Drawing.Size(160, 24)
Me.chkCompletedYN.TabIndex = 13
Me.chkCompletedYN.Tag = ""
Me.chkCompletedYN.Text = "Job Completed"
'
'chkApprovedYN
'
Me.chkApprovedYN.Location = New System.Drawing.Point(744, 448)
Me.chkApprovedYN.Name = "chkApprovedYN"
Me.chkApprovedYN.Size = New System.Drawing.Size(160, 24)
Me.chkApprovedYN.TabIndex = 12
Me.chkApprovedYN.Tag = ""
Me.chkApprovedYN.Text = "Approved for Programming"
'
'labUserNote
'
Me.labUserNote.Location = New System.Drawing.Point(328, 568)
Me.labUserNote.Name = "labUserNote"
Me.labUserNote.Size = New System.Drawing.Size(64, 23)
Me.labUserNote.TabIndex = 10
Me.labUserNote.Tag = ""
Me.labUserNote.Text = "User Note:"
'
'labReferenceJobNumber
'
Me.labReferenceJobNumber.Location = New System.Drawing.Point(8, 448)
Me.labReferenceJobNumber.Name = "labReferenceJobNumber"
Me.labReferenceJobNumber.TabIndex = 8
Me.labReferenceJobNumber.Tag = ""
Me.labReferenceJobNumber.Text = "Job Ref. Num. :"
'
'txtJobDescription
'
Me.txtJobDescription.BackColor = System.Drawing.SystemColors.Info
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtJobDescription,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtJobDesc ription,
MSDNTextboxValidator.DataTypeConstants.StringType)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtJobD escription,
"JobDescription")
Me.txtJobDescription.Location = New System.Drawing.Point(120, 424)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtJobDesc ription, "")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtJobDesc ription, "")
Me.txtJobDescription.Name = "txtJobDescription"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtJobDescription,
"")
Me.MsdnTextboxValidator1.SetRequired(Me.txtJobDesc ription, False)
Me.txtJobDescription.Size = New System.Drawing.Size(300, 20)
Me.txtJobDescription.TabIndex = 7
Me.txtJobDescription.Tag = ""
Me.txtJobDescription.Text = ""
Me.ToolTip1.SetToolTip(Me.txtJobDescription, "Please enter a maximum
of 75 letters.")
'
'labJobDescription
'
Me.labJobDescription.Location = New System.Drawing.Point(8, 424)
Me.labJobDescription.Name = "labJobDescription"
Me.labJobDescription.TabIndex = 6
Me.labJobDescription.Tag = ""
Me.labJobDescription.Text = "Job Description:"
'
'labCustomerName
'
Me.labCustomerName.Location = New System.Drawing.Point(8, 400)
Me.labCustomerName.Name = "labCustomerName"
Me.labCustomerName.TabIndex = 4
Me.labCustomerName.Tag = ""
Me.labCustomerName.Text = "Customer Name:"
'
'labJobNumber
'
Me.labJobNumber.Location = New System.Drawing.Point(8, 376)
Me.labJobNumber.Name = "labJobNumber"
Me.labJobNumber.TabIndex = 2
Me.labJobNumber.Tag = ""
Me.labJobNumber.Text = "Job Number:"
'
'txtJobNumber
'
Me.txtJobNumber.BackColor = System.Drawing.SystemColors.Info
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtJobNumber,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtJobNumb er,
MSDNTextboxValidator.DataTypeConstants.StringType)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtJobN umber, "JobNumber")
Me.txtJobNumber.Location = New System.Drawing.Point(120, 376)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtJobNumb er, "")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtJobNumb er, "")
Me.txtJobNumber.Name = "txtJobNumber"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtJobNumber,
"^[a-zA-Z]{1,3}[0-9]{4}$")
Me.MsdnTextboxValidator1.SetRequired(Me.txtJobNumb er, False)
Me.txtJobNumber.TabIndex = 3
Me.txtJobNumber.Tag = ""
Me.txtJobNumber.Text = ""
Me.ToolTip1.SetToolTip(Me.txtJobNumber, "Please enter a pattern of
1-3 letters and 4 numbers.")
'
'txtUserNote
'
Me.txtUserNote.BackColor = System.Drawing.SystemColors.Window
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtUserNote,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtUserNot e,
MSDNTextboxValidator.DataTypeConstants.StringType)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtUser Note, "")
Me.txtUserNote.Location = New System.Drawing.Point(392, 568)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtUserNot e, "")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtUserNot e, "")
Me.txtUserNote.Multiline = True
Me.txtUserNote.Name = "txtUserNote"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtUserNote, "")
Me.MsdnTextboxValidator1.SetRequired(Me.txtUserNot e, False)
Me.txtUserNote.Size = New System.Drawing.Size(300, 40)
Me.txtUserNote.TabIndex = 11
Me.txtUserNote.Tag = ""
Me.txtUserNote.Text = ""
Me.ToolTip1.SetToolTip(Me.txtUserNote, "Users notes such what
information might need verification.")
'
'grpSystemServices
'
Me.grpSystemServices.Controls.Add(Me.chkHasCircuit BreakersYN)
Me.grpSystemServices.Controls.Add(Me.txtSystemAmps )
Me.grpSystemServices.Controls.Add(Me.labSystemAmps )
Me.grpSystemServices.Controls.Add(Me.cboSystemPhas e)
Me.grpSystemServices.Controls.Add(Me.labSystemPhas e)
Me.grpSystemServices.Controls.Add(Me.cboSystemVolt age)
Me.grpSystemServices.Controls.Add(Me.labSystemVolt age)
Me.grpSystemServices.Controls.Add(Me.txtShopPSI)
Me.grpSystemServices.Controls.Add(Me.labShopPsi)
Me.grpSystemServices.Location = New System.Drawing.Point(432, 368)
Me.grpSystemServices.Name = "grpSystemServices"
Me.grpSystemServices.Size = New System.Drawing.Size(304, 152)
Me.grpSystemServices.TabIndex = 9
Me.grpSystemServices.TabStop = False
Me.grpSystemServices.Tag = ""
Me.grpSystemServices.Text = "System Services"
'
'chkHasCircuitBreakersYN
'
Me.chkHasCircuitBreakersYN.Location = New System.Drawing.Point(120,
120)
Me.chkHasCircuitBreakersYN.Name = "chkHasCircuitBreakersYN"
Me.chkHasCircuitBreakersYN.Size = New System.Drawing.Size(176, 24)
Me.chkHasCircuitBreakersYN.TabIndex = 8
Me.chkHasCircuitBreakersYN.Text = "Circuit Brakers (Fuses default)"
'
'txtSystemAmps
'
Me.txtSystemAmps.BackColor = System.Drawing.SystemColors.Info
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtSystemAmps,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtSystemA mps,
MSDNTextboxValidator.DataTypeConstants.Int16Type)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtSyst emAmps,
"SystemAmps")
Me.txtSystemAmps.Location = New System.Drawing.Point(120, 96)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtSystemA mps, "999")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtSystemA mps, "0")
Me.txtSystemAmps.Name = "txtSystemAmps"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtSystemAmps, "")
Me.MsdnTextboxValidator1.SetRequired(Me.txtSystemA mps, False)
Me.txtSystemAmps.TabIndex = 7
Me.txtSystemAmps.Text = ""
Me.ToolTip1.SetToolTip(Me.txtSystemAmps, "Please enter an Integer
between 0 and 999.")
'
'labSystemAmps
'
Me.labSystemAmps.Location = New System.Drawing.Point(8, 96)
Me.labSystemAmps.Name = "labSystemAmps"
Me.labSystemAmps.TabIndex = 6
Me.labSystemAmps.Text = "System Amps"
'
'cboSystemPhase
'
Me.cboSystemPhase.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboSystemPhase.Location = New System.Drawing.Point(120, 72)
Me.cboSystemPhase.Name = "cboSystemPhase"
Me.cboSystemPhase.Size = New System.Drawing.Size(121, 21)
Me.cboSystemPhase.TabIndex = 5
'
'labSystemPhase
'
Me.labSystemPhase.Location = New System.Drawing.Point(8, 72)
Me.labSystemPhase.Name = "labSystemPhase"
Me.labSystemPhase.TabIndex = 4
Me.labSystemPhase.Text = "System Phase:"
'
'cboSystemVoltage
'
Me.cboSystemVoltage.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboSystemVoltage.Location = New System.Drawing.Point(120, 48)
Me.cboSystemVoltage.Name = "cboSystemVoltage"
Me.cboSystemVoltage.Size = New System.Drawing.Size(72, 21)
Me.cboSystemVoltage.TabIndex = 3
'
'labSystemVoltage
'
Me.labSystemVoltage.Location = New System.Drawing.Point(8, 48)
Me.labSystemVoltage.Name = "labSystemVoltage"
Me.labSystemVoltage.TabIndex = 2
Me.labSystemVoltage.Text = "System Voltage:"
'
'txtShopPSI
'
Me.txtShopPSI.BackColor = System.Drawing.SystemColors.Info
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtShopPSI,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtShopPSI ,
MSDNTextboxValidator.DataTypeConstants.Int16Type)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtShop PSI, "ShipPSI")
Me.txtShopPSI.Location = New System.Drawing.Point(120, 24)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtShopPSI , "999")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtShopPSI , "0")
Me.txtShopPSI.Name = "txtShopPSI"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtShopPSI, "")
Me.MsdnTextboxValidator1.SetRequired(Me.txtShopPSI , False)
Me.txtShopPSI.TabIndex = 1
Me.txtShopPSI.Tag = "DataEntry"
Me.txtShopPSI.Text = ""
Me.ToolTip1.SetToolTip(Me.txtShopPSI, "Please enter an Integer
between 0 and 999.")
'
'labShopPsi
'
Me.labShopPsi.Location = New System.Drawing.Point(8, 24)
Me.labShopPsi.Name = "labShopPsi"
Me.labShopPsi.TabIndex = 0
Me.labShopPsi.Tag = "DataEntry"
Me.labShopPsi.Text = "Shop PSI (80):"
'
'chkIsMasterYN
'
Me.chkIsMasterYN.Location = New System.Drawing.Point(744, 496)
Me.chkIsMasterYN.Name = "chkIsMasterYN"
Me.chkIsMasterYN.Size = New System.Drawing.Size(160, 24)
Me.chkIsMasterYN.TabIndex = 14
Me.chkIsMasterYN.Tag = ""
Me.chkIsMasterYN.Text = "This Job is the Master"
'
'lblReferenceJobNumber
'
Me.lblReferenceJobNumber.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D
Me.lblReferenceJobNumber.Location = New System.Drawing.Point(120,
448)
Me.lblReferenceJobNumber.Name = "lblReferenceJobNumber"
Me.lblReferenceJobNumber.TabIndex = 9
Me.lblReferenceJobNumber.Tag = ""
'
'chkAllProcessesAddedYN
'
Me.chkAllProcessesAddedYN.Enabled = False
Me.chkAllProcessesAddedYN.Location = New System.Drawing.Point(744,
376)
Me.chkAllProcessesAddedYN.Name = "chkAllProcessesAddedYN"
Me.chkAllProcessesAddedYN.Size = New System.Drawing.Size(160, 24)
Me.chkAllProcessesAddedYN.TabIndex = 26
Me.chkAllProcessesAddedYN.Tag = ""
Me.chkAllProcessesAddedYN.Text = "All Processes Added"
'
'chkAllProcessesConfiguredYN
'
Me.chkAllProcessesConfiguredYN.Enabled = False
Me.chkAllProcessesConfiguredYN.Location = New
System.Drawing.Point(744, 424)
Me.chkAllProcessesConfiguredYN.Name = "chkAllProcessesConfiguredYN"
Me.chkAllProcessesConfiguredYN.Size = New System.Drawing.Size(160,
24)
Me.chkAllProcessesConfiguredYN.TabIndex = 27
Me.chkAllProcessesConfiguredYN.Tag = ""
Me.chkAllProcessesConfiguredYN.Text = "All Processes Configured"
'
'chkArchive
'
Me.chkArchive.Location = New System.Drawing.Point(744, 520)
Me.chkArchive.Name = "chkArchive"
Me.chkArchive.Size = New System.Drawing.Size(160, 24)
Me.chkArchive.TabIndex = 28
Me.chkArchive.Tag = ""
Me.chkArchive.Text = "Archive (hide)"
'
'txtCustomerName
'
Me.txtCustomerName.BackColor = System.Drawing.SystemColors.Info
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtCustomerName,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtCustome rName,
MSDNTextboxValidator.DataTypeConstants.StringType)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtCust omerName,
"CustomerName")
Me.txtCustomerName.Location = New System.Drawing.Point(120, 400)
Me.txtCustomerName.MaxLength = 36
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtCustome rName, "")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtCustome rName, "")
Me.txtCustomerName.Name = "txtCustomerName"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtCustomerName, "")
Me.MsdnTextboxValidator1.SetRequired(Me.txtCustome rName, False)
Me.txtCustomerName.Size = New System.Drawing.Size(200, 20)
Me.txtCustomerName.TabIndex = 35
Me.txtCustomerName.Tag = ""
Me.txtCustomerName.Text = ""
Me.ToolTip1.SetToolTip(Me.txtCustomerName, "Please enter a maximum of
36 letters.")
'
'lblCountOfJobs
'
Me.lblCountOfJobs.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D
Me.lblCountOfJobs.ForeColor = System.Drawing.SystemColors.GrayText
Me.lblCountOfJobs.Location = New System.Drawing.Point(120, 328)
Me.lblCountOfJobs.Name = "lblCountOfJobs"
Me.lblCountOfJobs.Size = New System.Drawing.Size(100, 16)
Me.lblCountOfJobs.TabIndex = 33
'
'labTotalJobs
'
Me.labTotalJobs.Location = New System.Drawing.Point(8, 328)
Me.labTotalJobs.Name = "labTotalJobs"
Me.labTotalJobs.Size = New System.Drawing.Size(100, 16)
Me.labTotalJobs.TabIndex = 32
Me.labTotalJobs.Text = "Total Jobs:"
'
'chkAllTasksAddedYN
'
Me.chkAllTasksAddedYN.Enabled = False
Me.chkAllTasksAddedYN.Location = New System.Drawing.Point(744, 400)
Me.chkAllTasksAddedYN.Name = "chkAllTasksAddedYN"
Me.chkAllTasksAddedYN.Size = New System.Drawing.Size(160, 24)
Me.chkAllTasksAddedYN.TabIndex = 34
Me.chkAllTasksAddedYN.Text = "All Tasks Added"
'
'MsdnTextboxValidator1
'
Me.MsdnTextboxValidator1.DisplayControl = Nothing
Me.MsdnTextboxValidator1.ErrorProvider = Me.ErrorProvider1
Me.MsdnTextboxValidator1.InvalidBackColor =
System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte),
CType(255, Byte))
Me.MsdnTextboxValidator1.TooltipProvider = Nothing
'
'ErrorProvider1
'
Me.ErrorProvider1.ContainerControl = Me
'
'txtEditedBy
'
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtEditedBy,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtEditedB y,
MSDNTextboxValidator.DataTypeConstants.StringType)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtEdit edBy, "")
Me.txtEditedBy.Location = New System.Drawing.Point(120, 552)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtEditedB y, "")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtEditedB y, "")
Me.txtEditedBy.Name = "txtEditedBy"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtEditedBy, "")
Me.MsdnTextboxValidator1.SetRequired(Me.txtEditedB y, False)
Me.txtEditedBy.TabIndex = 72
Me.txtEditedBy.Tag = "RecordDoc"
Me.txtEditedBy.Text = ""
'
'txtEditedOn
'
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtEditedOn,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtEditedO n,
MSDNTextboxValidator.DataTypeConstants.StringType)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtEdit edOn, "")
Me.txtEditedOn.Location = New System.Drawing.Point(120, 528)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtEditedO n, "")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtEditedO n, "")
Me.txtEditedOn.Name = "txtEditedOn"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtEditedOn, "")
Me.MsdnTextboxValidator1.SetRequired(Me.txtEditedO n, False)
Me.txtEditedOn.Size = New System.Drawing.Size(150, 20)
Me.txtEditedOn.TabIndex = 70
Me.txtEditedOn.Tag = "RecordDoc"
Me.txtEditedOn.Text = ""
'
'txtCreatedBy
'
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtCreatedBy,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtCreated By,
MSDNTextboxValidator.DataTypeConstants.StringType)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtCrea tedBy, "")
Me.txtCreatedBy.Location = New System.Drawing.Point(120, 504)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtCreated By, "")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtCreated By, "")
Me.txtCreatedBy.Name = "txtCreatedBy"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtCreatedBy, "")
Me.MsdnTextboxValidator1.SetRequired(Me.txtCreated By, False)
Me.txtCreatedBy.TabIndex = 68
Me.txtCreatedBy.Tag = "RecordDoc"
Me.txtCreatedBy.Text = ""
'
'txtCreatedOn
'
Me.MsdnTextboxValidator1.SetCustomValidationEnable d(Me.txtCreatedOn,
True)
Me.MsdnTextboxValidator1.SetDataType(Me.txtCreated On,
MSDNTextboxValidator.DataTypeConstants.StringType)
Me.MsdnTextboxValidator1.SetDisplayName(Me.txtCrea tedOn, "")
Me.txtCreatedOn.Location = New System.Drawing.Point(120, 480)
Me.MsdnTextboxValidator1.SetMaxValue(Me.txtCreated On, "")
Me.MsdnTextboxValidator1.SetMinValue(Me.txtCreated On, "")
Me.txtCreatedOn.Name = "txtCreatedOn"
Me.MsdnTextboxValidator1.SetRegularExpression(Me.t xtCreatedOn, "")
Me.MsdnTextboxValidator1.SetRequired(Me.txtCreated On, False)
Me.txtCreatedOn.Size = New System.Drawing.Size(150, 20)
Me.txtCreatedOn.TabIndex = 66
Me.txtCreatedOn.Tag = "RecordDoc"
Me.txtCreatedOn.Text = ""
'
'lblCountOfConfigured
'
Me.lblCountOfConfigured.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D
Me.lblCountOfConfigured.ForeColor =
System.Drawing.SystemColors.GrayText
Me.lblCountOfConfigured.Location = New System.Drawing.Point(352, 328)
Me.lblCountOfConfigured.Name = "lblCountOfConfigured"
Me.lblCountOfConfigured.Size = New System.Drawing.Size(100, 16)
Me.lblCountOfConfigured.TabIndex = 37
'
'labTotalConfigured
'
Me.labTotalConfigured.Location = New System.Drawing.Point(240, 328)
Me.labTotalConfigured.Name = "labTotalConfigured"
Me.labTotalConfigured.Size = New System.Drawing.Size(100, 16)
Me.labTotalConfigured.TabIndex = 36
Me.labTotalConfigured.Text = "Total Configured:"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(320, 480)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 38
Me.Button1.Text = "Button1"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(320, 512)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 39
Me.Button2.Text = "Button2"
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(848, 584)
Me.btnExit.Name = "btnExit"
Me.btnExit.TabIndex = 63
Me.btnExit.Text = "Close"
'
'labEditedBy
'
Me.labEditedBy.Location = New System.Drawing.Point(8, 552)
Me.labEditedBy.Name = "labEditedBy"
Me.labEditedBy.TabIndex = 71
Me.labEditedBy.Tag = "RecordDoc"
Me.labEditedBy.Text = "Edited By:"
'
'labEditedOn
'
Me.labEditedOn.Location = New System.Drawing.Point(8, 528)
Me.labEditedOn.Name = "labEditedOn"
Me.labEditedOn.TabIndex = 69
Me.labEditedOn.Tag = "RecordDoc"
Me.labEditedOn.Text = "Edited On:"
'
'labCreatedBy
'
Me.labCreatedBy.Location = New System.Drawing.Point(8, 504)
Me.labCreatedBy.Name = "labCreatedBy"
Me.labCreatedBy.TabIndex = 67
Me.labCreatedBy.Tag = "RecordDoc"
Me.labCreatedBy.Text = "Created By:"
'
'labCreatedOn
'
Me.labCreatedOn.Location = New System.Drawing.Point(8, 480)
Me.labCreatedOn.Name = "labCreatedOn"
Me.labCreatedOn.TabIndex = 65
Me.labCreatedOn.Tag = "RecordDoc"
Me.labCreatedOn.Text = "Created On:"
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(8, 120)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(920, 200)
Me.DataGrid1.TabIndex = 0
'
'f010Jobs
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(944, 644)
Me.Controls.Add(Me.txtEditedBy)
Me.Controls.Add(Me.txtEditedOn)
Me.Controls.Add(Me.txtCreatedBy)
Me.Controls.Add(Me.txtCreatedOn)
Me.Controls.Add(Me.labEditedBy)
Me.Controls.Add(Me.labEditedOn)
Me.Controls.Add(Me.labCreatedBy)
Me.Controls.Add(Me.labCreatedOn)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.lblCountOfConfigured)
Me.Controls.Add(Me.labTotalConfigured)
Me.Controls.Add(Me.txtCustomerName)
Me.Controls.Add(Me.chkAllTasksAddedYN)
Me.Controls.Add(Me.lblCountOfJobs)
Me.Controls.Add(Me.labTotalJobs)
Me.Controls.Add(Me.chkArchive)
Me.Controls.Add(Me.chkAllProcessesConfiguredYN)
Me.Controls.Add(Me.chkAllProcessesAddedYN)
Me.Controls.Add(Me.lblReferenceJobNumber)
Me.Controls.Add(Me.chkIsMasterYN)
Me.Controls.Add(Me.grpSystemServices)
Me.Controls.Add(Me.txtUserNote)
Me.Controls.Add(Me.txtJobNumber)
Me.Controls.Add(Me.lblpkJobId)
Me.Controls.Add(Me.labJobId)
Me.Controls.Add(Me.chkCompletedYN)
Me.Controls.Add(Me.chkApprovedYN)
Me.Controls.Add(Me.labUserNote)
Me.Controls.Add(Me.labReferenceJobNumber)
Me.Controls.Add(Me.txtJobDescription)
Me.Controls.Add(Me.labJobDescription)
Me.Controls.Add(Me.labCustomerName)
Me.Controls.Add(Me.labJobNumber)
Me.Name = "f010Jobs"
Me.Text = "f010Jobs"
Me.grpSystemServices.ResumeLayout(False)
CType(Me.DataGrid1,
System.ComponentModel.ISupportInitialize).EndInit( )
Me.ResumeLayout(False)

End Sub

#End Region

Protected DAL As New CLIP.DataAccess
Protected _dataSet1 As CLIP.dsTables
Protected _currentTable As String
Protected _dt As DataTable

Protected WithEvents _bmb As BindingManagerBase

'ComboBox Control
Private _bStillPopulatingCboVoltage As Boolean = True
Private _bStillPopulatingCboPhase As Boolean = True

Protected Sub DataGrid1_CurrentCellChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
_bmb.Position = DataGrid1.CurrentCell.RowNumber
End Sub

Private Sub Form_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me._dataSet1 = New CLIP.dsTables

_currentTable = "tbl010Job"
_dt = _dataSet1.tbl010Job

Call FillDataSet()
Call SetBindings()

End Sub

Private Sub FillDataSet()
DAL.sqlConn.Open()
DAL.da104Voltage_Cbo.Fill(_dataSet1, "lkp104Voltage")
DAL.da102Phase_Cbo.Fill(_dataSet1, "lkp102Phase")
DAL.da010JobFrm.Fill(_dataSet1, "tbl010Job")
DAL.sqlConn.Close()
DAL.sqlConn.Close()
End Sub

Private Sub SetBindings()

'[ComboBox]
Me.cboSystemVoltage.DataSource = _dataSet1
Me.cboSystemVoltage.DisplayMember = "lkp104Voltage.Voltage"
Me.cboSystemVoltage.ValueMember = "lkp104Voltage.pkVoltageId"

Me.cboSystemPhase.DataSource = _dataSet1
Me.cboSystemPhase.DisplayMember = "lkp102Phase.Phase"
Me.cboSystemPhase.ValueMember = "lkp102Phase.pkPhaseId"

'[DataGrid]
Me.DataGrid1.DataMember = "tbl010Job"
Me.DataGrid1.DataSource = _dataSet1

'[Controls]
Me.lblpkJobId.DataBindings.Add("Text", _dt, "pkJobId")
Me.txtJobNumber.DataBindings.Add("Text", _dt, "JobNumber")
Me.txtCustomerName.DataBindings.Add("Text", _dt, "CustomerName")
Me.txtJobDescription.DataBindings.Add("Text", _dt, "JobDescription")
Me.lblReferenceJobNumber.DataBindings.Add("Text", _dt,
"ReferenceJobNumber")

Me.txtShopPSI.DataBindings.Add("Text", _dt, "ShopPsi")
Me.cboSystemVoltage.DataBindings.Add("SelectedValu e", _dt,
"SystemVoltage")
Me.cboSystemPhase.DataBindings.Add("SelectedValue" , _dt,
"SystemPhase")
Me.txtSystemAmps.DataBindings.Add("Text", _dt, "SystemAmps")
Me.chkHasCircuitBreakersYN.DataBindings.Add("Check ed", _dt,
"HasCircuitBreakersYN")

Me.chkAllProcessesAddedYN.DataBindings.Add("Checke d", _dt,
"AllProcessesAddedYN")
Me.chkAllTasksAddedYN.DataBindings.Add("Checked", _dt,
"AllTasksAddedYN")
Me.chkAllProcessesConfiguredYN.DataBindings.Add("C hecked", _dt,
"AllProcessesConfiguredYN")
Me.chkApprovedYN.DataBindings.Add("Checked", _dt, "ApprovedYN")
Me.chkCompletedYN.DataBindings.Add("Checked", _dt, "CompletedYN")
Me.chkIsMasterYN.DataBindings.Add("Checked", _dt, "IsMasterYN")
Me.chkArchive.DataBindings.Add("Checked", _dt, "Archive")

Me.txtUserNote.DataBindings.Add("Text", _dt, "jcUserNote")
Me.txtCreatedOn.DataBindings.Add("Text", _dt, "jcCreatedOn")
Me.txtCreatedBy.DataBindings.Add("Text", _dt, "jcCreatedBy")
Me.txtEditedOn.DataBindings.Add("Text", _dt, "jcEditedOn")
Me.txtEditedBy.DataBindings.Add("Text", _dt, "jcEditedBy")

'[BindingContext]
_bmb = Me.BindingContext(_dt)
_bmb.Position = 0

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub

End Class
//

======================
2.) Here are (3) Data Tables (1 data table, two lookups)
\\
CREATE TABLE [tbl010Job] (
[pkJobId] [char] (36) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
CONSTRAINT [DF_tbl010JobCustomer_pkJobId] DEFAULT (newid()),
[JobNumber] [varchar] (7) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[CustomerName] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[JobDescription] [varchar] (75) COLLATE SQL_Latin1_General_CP1_CI_AS
NOT NULL ,
[ReferenceJobNumber] [varchar] (7) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[ShopPsi] [tinyint] NULL ,
[SystemVoltage] [int] NULL ,
[SystemPhase] [int] NULL ,
[SystemAmps] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[HasCircuitBreakersYN] [bit] NOT NULL CONSTRAINT
[DF_tbl010Job_HasCircuitBreakersYN] DEFAULT (0),
[AllProcessesAddedYN] [bit] NOT NULL CONSTRAINT
[DF_tbl010Job_AllProcessesPresentYN] DEFAULT (0),
[AllProcessesConfiguredYN] [bit] NOT NULL CONSTRAINT
[DF_tbl010Job_AllChildConfigsCompleteYN] DEFAULT (0),
[ApprovedYN] [bit] NOT NULL CONSTRAINT [DF_tbl010Job_ApprovedYN]
DEFAULT (0),
[CompletedYN] [bit] NOT NULL CONSTRAINT [DF_tbl010Job_CompletedYN]
DEFAULT (0),
[IsMasterYN] [bit] NOT NULL CONSTRAINT [DF_tbl010Job_IsMasterYN]
DEFAULT (0),
[Archive] [bit] NOT NULL CONSTRAINT [DF_tbl010Job_ARCHIVE] DEFAULT
(0),
[jcUserNote] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[jcCreatedOn] [smalldatetime] NOT NULL ,
[jcCreatedBy] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[jcEditedOn] [smalldatetime] NOT NULL ,
[jcEditedBy] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[jcrowversion] [timestamp] NOT NULL ,
[AllTasksAddedYN] [bit] NOT NULL CONSTRAINT
[DF_tbl010Job_AllTasksAddedYN] DEFAULT (0),
CONSTRAINT [PK_tbl010Job] PRIMARY KEY CLUSTERED
(
[pkJobId]
) ON [PRIMARY]
) ON [PRIMARY]
GO
//

\\
CREATE TABLE [lkp102Phase] (
[pkPhaseId] [int] IDENTITY (1, 1) NOT NULL ,
[Phase] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Ord] [tinyint] NOT NULL CONSTRAINT [DF_lkp102Phase_ord] DEFAULT (0),
[Hide] [bit] NOT NULL CONSTRAINT [DF_lkp102Phase_hide] DEFAULT (0),
CONSTRAINT [PK_lkp102Phase] PRIMARY KEY CLUSTERED
(
[pkPhaseId]
) ON [PRIMARY]
) ON [PRIMARY]
GO
//

\\
CREATE TABLE [lkp104Voltage] (
[pkVoltageId] [int] IDENTITY (1, 1) NOT NULL ,
[Voltage] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
,
[Ord] [tinyint] NOT NULL CONSTRAINT [DF_lkp104Voltage_ord] DEFAULT
(0),
[Hide] [bit] NOT NULL CONSTRAINT [DF_lkp104Voltage_hide] DEFAULT (0),
CONSTRAINT [PK_lkp104Voltage] PRIMARY KEY CLUSTERED
(
[pkVoltageId]
) ON [PRIMARY]
) ON [PRIMARY]
GO
//

======================
3.) Here is sample data

\\
pkJobId,JobNumber,CustomerName,JobDescription,Refe renceJobNumber,ShopPsi,SystemVoltage,SystemPhase,S ystemAmps,HasCircuitBreakersYN,AllProcessesAddedYN ,AllProcessesConfiguredYN,ApprovedYN,CompletedYN,I sMasterYN,Archive,jcUserNote,jcCreatedOn,jcCreated By,jcEditedOn,jcEditedBy,jcrowversion,AllTasksAdde dYN
166aba12-e302-4e1e-9723-299ed9a40aad,P1161,Plastech,DCX RH/LH A Piller
Cap
Clip,,75,2,3,100,TRUE,FALSE,FALSE,FALSE,FALSE,FALS E,FALSE,,9/1/2005,dbuchanan,9/6/2005,dbuchanan,00000000000163DE,FALSE
582E2CC9-BCDF-49C4-ACE1-3697DEF54A53,F1136,Frax,To this do
that,,,,,,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALS E,,9/12/2005,db,9/12/2005,db,000000000001641C,FALSE
5F8E9720-4C24-47AF-B7E1-7168784BE30A,G1137,Graxton,Something
else,,,,,,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALS E,,9/12/2005,db,9/12/2005,db,000000000001641E,FALSE
//

lkp102Phase
\\
1,DC,1,0
2,1-Pase,2,0
3,2-Phase,3,0
4,3-Phase,4,0
//

lkp104Voltage
\\
1,24,1,0
2,120,2,0
3,240,3,0
4,480,4,0
5,500,5,0
//

======================
4.) Here is the data set (dsTables.vb)
\\
Public Class dsTables
Inherits DataSet

'[DataTables]
Friend tbl010Job As New DataTable
Friend lkp102Phase As New DataTable
Friend lkp104Voltage As New DataTable

'[Constructor]
Public Sub New()
MyBase.New()
Call InitializeComponent()
End Sub

'[Initialize class component]
Private Sub InitializeComponent()

'[Add Tables to the DataSet]
Me.tbl010Job = Me.Tables.Add("tbl010Job")
Me.lkp102Phase = Me.Tables.Add("lkp102Phase")
Me.lkp104Voltage = Me.Tables.Add("lkp104Voltage")

'[Add Columns to the DataTables]

' tbl010Job
Dim pkJobId As DataColumn = Me.tbl010Job.Columns.Add("pkJobId",
GetType(String)) : pkJobId.MaxLength = 36 : pkJobId.AllowDBNull = False
Dim JobNumber As DataColumn =
Me.tbl010Job.Columns.Add("JobNumber", GetType(String)) :
JobNumber.MaxLength = 7 : JobNumber.AllowDBNull = False
Dim CustomerName As DataColumn =
Me.tbl010Job.Columns.Add("CustomerName", GetType(String)) :
CustomerName.MaxLength = 25 : CustomerName.AllowDBNull = False
Dim JobDescription As DataColumn =
Me.tbl010Job.Columns.Add("JobDescription", GetType(String)) :
JobDescription.MaxLength = 75 : JobDescription.AllowDBNull = False
Dim ReferenceJobNumber As DataColumn =
Me.tbl010Job.Columns.Add("ReferenceJobNumber", GetType(String)) :
ReferenceJobNumber.MaxLength = 7 : ReferenceJobNumber.AllowDBNull =
True

Dim ShopPsi As DataColumn = Me.tbl010Job.Columns.Add("ShopPsi",
GetType(Byte)) : ShopPsi.AllowDBNull = True 'ShopPsi.DefaultValue = 80
'Would this send the value to a new row? 'TODO - dsTables -
DatsColumn.DefaultValue
Dim SystemVoltage As DataColumn =
Me.tbl010Job.Columns.Add("SystemVoltage", GetType(Int32)) :
SystemVoltage.AllowDBNull = True
Dim SystemPhase As DataColumn =
Me.tbl010Job.Columns.Add("SystemPhase", GetType(Int32)) :
SystemPhase.AllowDBNull = True
Dim SystemAmps As DataColumn =
Me.tbl010Job.Columns.Add("SystemAmps", GetType(String)) :
SystemAmps.MaxLength = 3 : SystemAmps.AllowDBNull = True
Dim HasCircuitBreakersYN As DataColumn =
Me.tbl010Job.Columns.Add("HasCircuitBreakersYN", GetType(Boolean)) :
HasCircuitBreakersYN.AllowDBNull = False

Dim AllProcessesAddedYN As DataColumn =
Me.tbl010Job.Columns.Add("AllProcessesAddedYN", GetType(Boolean)) :
AllProcessesAddedYN.AllowDBNull = False
Dim AllTasksAddedYN As DataColumn =
Me.tbl010Job.Columns.Add("AllTasksAddedYN", GetType(Boolean)) :
AllTasksAddedYN.AllowDBNull = False
Dim AllProcessesConfiguredYN As DataColumn =
Me.tbl010Job.Columns.Add("AllProcessesConfiguredYN ", GetType(Boolean))
: AllProcessesConfiguredYN.AllowDBNull = False
Dim ApprovedYN As DataColumn =
Me.tbl010Job.Columns.Add("ApprovedYN", GetType(Boolean)) :
ApprovedYN.AllowDBNull = False
Dim CompletedYN As DataColumn =
Me.tbl010Job.Columns.Add("CompletedYN", GetType(Boolean)) :
CompletedYN.AllowDBNull = False
Dim IsMasterYN As DataColumn =
Me.tbl010Job.Columns.Add("IsMasterYN", GetType(Boolean)) :
IsMasterYN.AllowDBNull = False
Dim Archive As DataColumn = Me.tbl010Job.Columns.Add("Archive",
GetType(Boolean)) : Archive.AllowDBNull = False

Dim jcUserNote As DataColumn = Me.tbl010Job.Columns.Add("jcUserNote",
GetType(String)) : jcUserNote.MaxLength = 100 : jcUserNote.AllowDBNull
= False
Dim jcCreatedOn As DataColumn =
Me.tbl010Job.Columns.Add("jcCreatedOn", GetType(DateTime)) :
jcCreatedOn.AllowDBNull = False
Dim jcCreatedBy As DataColumn =
Me.tbl010Job.Columns.Add("jcCreatedBy", GetType(String)) :
jcCreatedBy.MaxLength = 25 : jcCreatedBy.AllowDBNull = False
Dim jcEditedOn As DataColumn =
Me.tbl010Job.Columns.Add("jcEditedOn", GetType(DateTime)) :
jcEditedOn.AllowDBNull = False
Dim jcEditedBy As DataColumn = Me.tbl010Job.Columns.Add("jcEditedBy",
GetType(String)) : jcEditedBy.MaxLength = 25 : jcEditedBy.AllowDBNull =
False

Dim jcrowversion As DataColumn =
Me.tbl010Job.Columns.Add("jcrowversion", GetType(Byte())) :
jcrowversion.AllowDBNull = True

' lkp102Phase
Dim pkPhaseId As DataColumn = Me.lkp102Phase.Columns.Add("pkPhaseId",
GetType(Int32)) : pkPhaseId.AllowDBNull = False
Dim Phase As DataColumn = Me.lkp102Phase.Columns.Add("Phase",
GetType(String)) : Phase.MaxLength = 50 : Phase.AllowDBNull = False
Dim Ord102 As DataColumn = Me.lkp102Phase.Columns.Add("Ord",
GetType(Byte)) : Ord102.AllowDBNull = False
Dim Hide102 As DataColumn = Me.lkp102Phase.Columns.Add("Hide",
GetType(Boolean)) : Hide102.AllowDBNull = False

' lkp104Voltage
Dim pkVoltageId As DataColumn =
Me.lkp104Voltage.Columns.Add("pkVoltageId", GetType(Int32)) :
pkVoltageId.AllowDBNull = False
Dim Voltage As DataColumn = Me.lkp104Voltage.Columns.Add("Voltage",
GetType(String)) : Voltage.MaxLength = 3 : Voltage.AllowDBNull = False
Dim Ord104 As DataColumn = Me.lkp104Voltage.Columns.Add("Ord",
GetType(Byte)) : Ord104.AllowDBNull = False
Dim Hide104 As DataColumn =
Me.lkp104Voltage.Columns.Add("Hide", GetType(Boolean)) :
Hide104.AllowDBNull = False

'[Simple PK Constraints - (one line)]
tbl010Job.PrimaryKey = New DataColumn()
{tbl010Job.Columns("pkJobID")}
lkp102Phase.PrimaryKey = New DataColumn()
{lkp102Phase.Columns("pkPhaseId")}
lkp104Voltage.PrimaryKey = New DataColumn()
{lkp104Voltage.Columns("pkVoltageId")}

End Sub

End Class
//

======================
5.) Here is the Data Access code (DataAccess.vb)

\\
Imports System.Data.SqlClient

Imports System.Data.Common
Imports System.Configuration

Public Class DataAccess
' This class is used to for full access to the main tables
' tbl010Job
' tbl020Proc
' tbl030Devi [2]
' tbl040Cmpt [7] [8] ~ use the same commands, but supply different
Stored Procedures

'This class is also used for access to the lookup tables for
comboBoxes
'See the other DataAccess Class named DataAccessLkpAdmin for code
' that allows administrative select, update, insert and delete on
those tables.

#Region " Variables - [ Connection | DataAdapters ] "

'=== [Connection] =================================
Friend sqlConn As New SqlConnection

'=== [DataAdapters] ===============================
Friend da010JobFrm As New SqlDataAdapter 'uses 'usp_Job_selVoltPhase'

'For ComboBoxes
Friend da102Phase_Cbo As New SqlDataAdapter ' for select only
Friend da104Voltage_Cbo As New SqlDataAdapter ' for select only

'=== [Commands] ==============================
Private Cmd010JobFrm_Sel As New SqlCommand
Private Cmd010JobFrm_Ins As New SqlCommand
Private Cmd010JobFrm_Upd As New SqlCommand
Private Cmd010JobFrm_Del As New SqlCommand

'=== [Commands - ComboBoxes] ========================
Private Cmd102Phase_Sel As New SqlCommand
Private Cmd104Voltage_Sel As New SqlCommand

#End Region

'[Constructor]
Public Sub New()
MyBase.New()
Call InitializeComponent()
End Sub

#Region " InitializeComponent - [ Instantiate (Connection,
DataAdapters, Commands), Give value (Connection String)] "

<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()

'=== [Connection String] ========================

Dim connectionString As String
connectionString =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Me.sqlConn.ConnectionString = connectionString

'=== [Set Cmds - Forms] ======================

With da010JobFrm
.SelectCommand = Cmd010JobFrm_Sel
.InsertCommand = Cmd010JobFrm_Ins
.UpdateCommand = Cmd010JobFrm_Upd
.DeleteCommand = Cmd010JobFrm_Del
End With

'=== [Set Cmds - ComboBoxes] ================

da102Phase_Cbo.SelectCommand = Cmd102Phase_Sel
da104Voltage_Cbo.SelectCommand = Cmd104Voltage_Sel

'### da010JobFrm ##################
'Select
With Cmd010JobFrm_Sel
.CommandType = CommandType.StoredProcedure
.CommandText = "usp_Job_sel_VoltPhase"
.Connection = sqlConn
With Cmd010JobFrm_Sel.Parameters
.Add(New SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4,
ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte),
"", DataRowVersion.Current, Nothing))
End With
End With

'%%% da102Phase_Cbo %%%%%%%%%%%%%%%%%
'Select
With Cmd102Phase_Sel
.CommandType = CommandType.StoredProcedure
.CommandText = "usp_102Phase_sel_cbo"
.Connection = sqlConn
With Cmd102Phase_Sel.Parameters
.Add(New SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4,
ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte),
"", DataRowVersion.Current, Nothing))
End With
End With

'%%% da104Voltage_Cbo %%%%%%%%%%%%%%%%
'Select
With Cmd104Voltage_Sel
.CommandType = CommandType.StoredProcedure
.CommandText = "usp_104Voltage_sel_cbo"
.Connection = sqlConn
With Cmd104Voltage_Sel.Parameters
.Add(New SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4,
ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte),
"", DataRowVersion.Current, Nothing))
End With
End With

End Sub

#End Region

End Class
//

======================
6.) Here are (3) stored procedures

"usp_Job_sel_VoltPhase"
\\
CREATE PROCEDURE dbo.usp_Job_sel_VoltPhase
AS SET NOCOUNT ON;
SELECT
j.pkJobId,
j.JobNumber,
j.CustomerName,
j.JobDescription,
j.ShopPsi,
j.SystemVoltage,
v.Voltage,
j.SystemPhase,
ph.Phase,
j.SystemAmps,
j.HasCircuitBreakersYN,
j.ReferenceJobNumber,

j.AllProcessesAddedYN,
j.AllProcessesConfiguredYN,
j.AllTasksAddedYN,
j.ApprovedYN,
j.CompletedYN,
j.IsMasterYN,
j.Archive,

j.jcUserNote,
j.jcCreatedOn,
j.jcCreatedBy,
j.jcEditedOn,
j.jcEditedBy,
j.jcrowversion

FROM
tbl010Job j
-- INNER JOIN lkp104Voltage v ON j.SystemVoltage = v. pkVoltageId
-- INNER JOIN lkp102Phase ph ON j.SystemPhase = ph. pkPhaseId
LEFT OUTER JOIN lkp104Voltage v ON j.SystemVoltage = v. pkVoltageId
LEFT OUTER JOIN lkp102Phase ph ON j.SystemPhase = ph. pkPhaseId

ORDER BY j.jcCreatedOn DESC

GO
//

"usp_102Phase_sel_cbo"
\\
CREATE PROCEDURE dbo.usp_102Phase_sel_cbo
AS
SET NOCOUNT ON;
SELECT
pkPhaseId,
Phase,
Ord,
Hide
FROM lkp102Phase
WHERE (Hide = 0)
Order By Ord, Phase

GO
//

"usp_104Voltage_sel_cbo"
\\
CREATE PROCEDURE dbo.usp_104Voltage_sel_cbo
AS
SET NOCOUNT ON;
SELECT
pkVoltageId,
Voltage,
Ord,
Hide
FROM lkp104Voltage
WHERE (Hide = 0)
ORDER BY Ord, Voltage

GO
//

Thank you for taking a look at this

Nov 21 '05 #6

P: n/a
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Not sure what you mean in number 5.
Here is what I mean by number 5...
This variable is created;

Protected WithEvents _bmb As BindingManagerBase

Then just after the controls binding I do this;
_bmb = Me.BindingContext(_dt)


Nothing wrong with storing a CurrencyManager, but for the connection between
DataGrid<->ComboBox, you don't need to handle any events. You are adding a
Binding to the ComboBox for SelectedValue, aren't you ?
What version of framework are you using ? DotNet framework 1.1.4322 SP1
Visual Studio 2003 Version 7.1.3088


Same here.
Maybe you could post the entire code that reproduces this problem ? I'll try to do this within a day.


Since a basic example seems to work for me, i can't say alot without seeing
any code.

hth,
Greetings

Nov 21 '05 #7

P: n/a
Hi Bart,

I sent my code earlier today. You should have it by now look above.

dbuchanan,
Thank you

Nov 21 '05 #8

P: n/a
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi Bart,
Maybe you could post the entire code that reproduces this problem ?


Here is the entire code necessary to reproduce the problem. (It is
simplified to contain only the code necessary)


First of all, you are correct that binding to lookup ComboBox's causes
problems with null values, i should have seen this earlier.

The main reason for this problem is that the ComboBox's have their own
CurrencyManager which mantain position. The position of a CurrencyManager
can not be -1 (no item selected), but the SelectedIndex of a ComboBox can
be -1 (no item selected). That's causing a conflict.
This first time the Position of the CurrencyManager will go to 0 instead
of -1, but since it has changed, the ComboBox sees this and updates its
SelectedIndex from -1 to 0. The second time it doesn't matter anymore, the
CurrencyManager stays at 0, doesn't fire any changing events and the
SelectedIndex of the ComboBox can stay at -1.

All that's left is a workaround, but first a correction:

1) I see that you are handling a cell changed event, you needed to do this
because the DataSource of the DataGrid and the Controls aren't exactly the
same.
Remove the cell changed event :

'Protected Sub DataGrid1_CurrentCellChanged(ByVal sender As Object,
' ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
' _bmb.Position = DataGrid1.CurrentCell.RowNumber
' End Sub

Then it is important to bind the DataGrid and your Controls to the same
DataSource, let's use _dt:

Private Sub SetBindings()
'[ComboBox]
' .... no need to change ....

'[DataGrid - using _dt ]
Me.DataGrid1.DataSource = _dt ' CHANGED

'[Controls - using _dt ]
Me.lblpkJobId.DataBindings.Add("Text", _dt, "pkJobId")
' ....

'[BindingContext - using _dt ]
_bmb = Me.BindingContext( _dt )

End Sub

Now the DataGrid and the Controls will navigate together without handling
the cell changed event.
2) A workaround for the null value problem:

Add the following code to the form, which handles the PositionChanged event
for the CurrencyManager you declared (_bmb) :

Private Sub _bmb_PositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles _bmb.PositionChanged
'
Dim lv As DataRowView = _
DirectCast(_bmb.Current, DataRowView)

Dim cbs() As ComboBox = _
New ComboBox() {cboSystemPhase, cboSystemVoltage}

For Each cbo As ComboBox In cbs
If
(lv(cbo.DataBindings("SelectedValue").BindingMembe rInfo.BindingField) Is
DBNull.Value) And _
(cbo.SelectedIndex <> -1) Then
cbo.SelectedIndex = -1
End If
Next
End Sub
hth,
Greetings
Nov 21 '05 #9

P: n/a
Hi Bart,

Thank you.I have implemented your suggestions and they work!

I have a question about the positon changed method in an environment of
inheritance. I use Protected Overridable in my base class and Protected
Overrides in my derived classes when I set my bindings. Is there a way
to implement _bmb_PositionChanged as a Protected Overridable and use
Protected Overrides to bring in the different combo boxes in the
derived forms. I don'e know how to do this when I already have method
parameters. For now I have a separate copy of the method in each of my
eight derived classes. I believe there should be a more practical way.

dbuchanan,
Thanks

Nov 21 '05 #10

P: n/a
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi Bart,

Thank you.I have implemented your suggestions and they work!

I have a question about the positon changed method in an environment of
inheritance. I use Protected Overridable in my base class and Protected
Overrides in my derived classes when I set my bindings. Is there a way
to implement _bmb_PositionChanged as a Protected Overridable and use
Protected Overrides to bring in the different combo boxes in the
derived forms. I don'e know how to do this when I already have method
parameters. For now I have a separate copy of the method in each of my
eight derived classes. I believe there should be a more practical way.
Putting workarounds into a design can be a challance and hardly fun.

If you could place the _bmb and a new PositionChanged handler in the base
class:

Class BaseForm
Inherits Form
'....
Protected WithEvents BindingManagerBase _bmb;

Private Sub _bmb_PositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles _bmb.PositionChanged
'
Dim lv As DataRowView = _
DirectCast(_bmb.Current, DataRowView)

Dim cb As ComboBox
For Each bnd As Binding In _bmb.Bindings
If (bnd.PropertyName = "SelectedValue") And _
(bnd.Control.GetType() Is GetType(ComboBox)) Then
cb = DirectCast(bnd.Control, ComboBox)
If (lv(bnd.BindingMemberInfo.BindingField) Is DBNull.Value) And
_
(cb.SelectedIndex <> -1) Then
cb.SelectedIndex = -1
End If
End If
Next
End Sub
End Class

Then this workaround will work for all ComboBox's whose SelectedValue is
bound to the same DataSource that you used to get _bmb, it doesn't matter
how much or where you bind them. You can also set _bmb inside the base or
derived class.

Not sure if this helps,

Greetings


dbuchanan,
Thanks

Nov 21 '05 #11

P: n/a
Hi Bart,

Thanks so much. It works.

(This opens up new coding approaches for me to master.)

dbuchanan

Nov 21 '05 #12

P: n/a
Hi Bart,

Help! - An important problem remains.

When I create a new row all comboBoxes default to selecting the very
first item. - The userI cannot create a record with no selection.

What do I do?

dbuchanan,
Thanks

Nov 21 '05 #13

P: n/a
Hi Bart,
Help! - An important problem remains.
When I create a new row all comboBoxes default to selecting the very
first item. - The userI cannot create a record with no selection.

== Additional Information ==
It matters which record the cursor is on when the "New Record" button
it pushed.

If the current datagrid record is one in which the combo boxes are
null the new record will be null as desired.
If the current datagrid record is one in which the combo box has a
selection already made the new record will be created with the combo
boxes pre selected on the first item.

=====================

What do I do?
dbuchanan,
Thanks

Nov 21 '05 #14

P: n/a
Hi,
"dbuchanan" <db*********@hotmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegr oups.com...Hi Bart,
Help! - An important problem remains.
When I create a new row all comboBoxes default to selecting the very
first item. - The userI cannot create a record with no selection.
== Additional Information ==
It matters which record the cursor is on when the "New Record" button
it pushed.
If the current datagrid record is one in which the combo boxes are
null the new record will be null as desired.
If the current datagrid record is one in which the combo box has a
selection already made the new record will be created with the combo
boxes pre selected on the first item.


I'm seeing something different when adding a new row in the datagrid,
basicly all fields keep the same values of the previous row and the row
selector in DataGrid doesn't change position. This is caused because of the
CheckBox's which don't accept a null either.

I see that your boolean DataColumns have AllowNull set to False, which is
good, but it is *important* you also set the DefaultValue to either False or
True.

see
http://support.microsoft.com/default...b;en-us;326440

If i set the default value for all boolean DataColumns (or have no checkbox)
then everything seems to work, new rows too.

----

I also found a different workaround taking another approach which maybe
easier to use with complex databinding, though it requires inheriting from a
ComboBox. ( see bottom )

Instead of using ComboBox you use NComboBox and instead of binding to
SelectedValue you bind to NSelectedValue, then you don't have to worry about
CurrencyManagers and stuff like that anymore (well at least not for the null
problem).

If you do want nullable CheckBox you could create a NCheckBox, but remember
if you don't want nullable CheckBox you need to set the DefaultValue for all
boolean DataColumns.

I also noticed the 'null ComboBox' problem is gone in NET2.0 beta2.
HTH,
Greetings

Public Class NComboBox
Inherits System.Windows.Forms.ComboBox

Public Property NSelectedValue() As Object
Get
Return SelectedValue
End Get
Set(ByVal Value As Object)
' SelectValue needs to be called twice
' for null value
SelectedValue = Value
If (Value Is DBNull.Value And SelectedIndex <> -1) Then
SelectedValue = Value
End If
End Set
End Property

End Class

===================== What do I do?
dbuchanan,
Thanks

Nov 21 '05 #15

P: n/a
Hi Bart,

A appreciate your continued assistance on this topic.

First I will address our original approach...

You said...
basicly all fields keep the same values of the previous row and the row selector in DataGrid doesn't change position.


There is a reason that this *does not* happen in my code. - I
pre-populate the controls with defaults. (come to think of it... I
don't set the comboBoxes to null at that time. - I don't know how to do
this ~ perhaps you can suggest something if this approach makes sense
to you)

What follows is a discription my current approach;

I *do* give default values to all checkBoxes. I did not show this in
the previous code because it was not relevant at the time... when I
create a new row I do the following;

User clicks NewRow button
1.) Data binding is suspend
2.) DataGrid is disabled
3.) Defaults are populated in the controls (see code below)

Then the user enters data and Clicks the Saves the (or the Cancels)
button. A save performs the following;

4.) The ID and documentation fields are assigned a GUID, date and the
username
5.) A dataRow is created, the row is populated with values from the
controls, the row is added to the dataset (see code below)
6.) The datasource updated
7.) Data bindings are resumed

[ 3.) from above ]
\\
Protected Overrides Sub PopulateControlDefaultsForNewRow()
' Primary Key GUID Value will be installed on save
Me.lblpkJobId.Text = "" ' Value will be installed on save
Me.txtJobNumber.Text = "" ' Required entry
Me.txtCustomerName.Text = "" ' Allow empty string
Me.txtJobDescription.Text = "" ' Allow empty string
Me.lblReferenceJobNumber.Text = "" ' (nullable) ~ auto populated

Me.txtShopPSI.Text = "" ' (nullable)
Me.cboSystemVoltage.Text = "" ' (nullable)
Me.cboSystemPhase.Text = "" ' (nullable)
Me.txtSystemAmps.Text = "" ' (nullable)
Me.chkHasCircuitBreakersYN.Checked = False

Me.chkAllProcessesAddedYN.Checked = False
Me.chkAllTasksAddedYN.Checked = False
Me.chkAllProcessesConfiguredYN.Checked = False
Me.chkApprovedYN.Checked = False
Me.chkCompletedYN.Checked = False
Me.chkIsMasterYN.Checked = False
Me.chkArchive.Checked = False

Me.txtUserNote.Text = "" ' Allow empty string
Me.txtCreatedOn.Text = "" ' Value will be installed on save
Me.txtCreatedBy.Text = "" ' Value will be installed on save
Me.txtEditedOn.Text = "" ' Value will be installed on save
Me.txtEditedBy.Text = "" ' Value will be installed on save
'jcrowversion
End Sub
//

[ 5.) from above ]
\\
Protected Overrides Sub InsertIntoDataset()

Dim row As DataRow = _dataSet1.Tables(_currentTable).NewRow

row("pkJobId") = Me.lblpkJobId.Text
row("JobNumber") = Me.txtJobNumber.Text
row("CustomerName") = Me.txtCustomerName.Text
row("JobDescription") = Me.txtJobDescription.Text

row("ReferenceJobNumber") = Me.lblReferenceJobNumber.Text

If Me.txtShopPSI.Text = "" Then ' DataType [Tinyint]
' If empty string then don't pass expression therefore Null
Else
row("ShopPsi") = Me.txtShopPSI.Text ' << the db stores this as short
or Int16
End If

If Me.cboSystemVoltage.SelectedIndex < 0 Then
'do nothing
Else
row("SystemVoltage") = Me.cboSystemVoltage.SelectedValue
End If

If Me.cboSystemPhase.SelectedIndex < 0 Then
'do nothing
Else
row("SystemPhase") = Me.cboSystemPhase.SelectedValue
End If

If Me.txtSystemAmps.Text = "" Then
' If empty string then don't pass expression therefore Null
Else
row("SystemAmps") = Me.txtSystemAmps.Text ' << the db stores this as
short or Int16
End If
row("HasCircuitBreakersYN") = Me.chkHasCircuitBreakersYN.Checked

row("AllProcessesAddedYN") = Me.chkAllProcessesAddedYN.Checked
row("AllTasksAddedYN") = Me.chkAllTasksAddedYN.Checked
row("AllProcessesConfiguredYN") =
Me.chkAllProcessesConfiguredYN.Checked
row("ApprovedYN") = Me.chkApprovedYN.Checked
row("CompletedYN") = Me.chkCompletedYN.Checked
row("IsMasterYN") = Me.chkIsMasterYN.Checked
row("Archive") = Me.chkArchive.Checked

row("jcUserNote") = Me.txtUserNote.Text
row("jcCreatedOn") = Me.txtCreatedOn.Text
row("jcCreatedBy") = Me.txtCreatedBy.Text
row("jcEditedOn") = Me.txtEditedOn.Text
row("jcEditedBy") = Me.txtEditedBy.Text
'jcrowversion

'Add this row to the DataSet
_dataSet1.Tables(_currentTable).Rows.Add(row)
End Sub
//

Based on the current approach what is the best solution? If I should
set the comboBoxes to null when I set the default values, how would I
to do this?

====================
Regarding your other suggestion, using NComboBox, how would I impliment
this approach?

After commenting out the other ComboBox references I tried the
following...

\\
Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

Friend WithEvents cboSystemPhase As NComboBox
Me.cboSystemPhase = New NComboBox

Me.grpSystemServices.Controls.Add(Me.cboSystemPhas e)

'cboSystemPhase
'
Me.cboSystemPhase.DropDownStyle = NComboBoxStyle.DropDownList
Me.cboSystemPhase.Location = New System.Drawing.Point(120, 72)
Me.cboSystemPhase.Name = "cboSystemPhase"
Me.cboSystemPhase.Size = New System.Drawing.Size(121, 21)
Me.cboSystemPhase.TabIndex = 5

End Sub
//

And

\\
Me.cboSystemPhase.DataBindings.Add("NSelectedValue ", _dt,
"SystemPhase")
//

But, how should it really done?

--
dbuchanan

Nov 21 '05 #16

P: n/a
Hi,

I hope i don't confuse you with two different workarounds, both workarounds
work by calling an additional SelectedIndex = -1 or SelectedValue =
DBNull.Value, because the ComboBox doesn't always respond to the first
setting.

1.
The first workaround i gave you, calls an additional SelectedIndex=-1 when
the position changes for all ComboBox whose SelectedValue should be null.
It doesn't really fix the ComboBox itself. Because the ComboBox isn't
really fixed, you will need to call SelectedValue twice when you set it
manually :

Protected Overrides Sub PopulateControlDefaultsForNewRow()
' ....
Me.cboSystemVoltage.SelectedValue = DBNull.Value ' twice for null
Me.cboSystemVoltage.SelectedValue = DBNull.Value

Me.cboSystemPhase.SelectedValue = DBNull.Value ' twice for null
Me.cboSystemPhase.SelectedValue = DBNull.Value

End Sub
2.
The second workaround ( NComboBox ) kind of fixes the ComboBox by providing
a new property NSelectedValue which works by setting it once. I prefer
this lastest workaround, it seems cleaner, no mess with CurrencyManagers. I
don't really know what doesn't work for you with NComboBox, you seem to be
using it correctly. You offcourse have to import the NComboBox code i gave
you into your project. If you use NComboBox and want to set a null value
from code, you only need to set NSelectedValue to DBNull.Value once:

Protected Overrides Sub PopulateControlDefaultsForNewRow()
' ....
Me.cboSystemVoltage.NSelectedValue = DBNull.Value ' once
Me.cboSystemPhase.NSelectedValue = DBNull.Value ' once

End Sub
For either workaround, you don't have to change InsertIntoDataset().
HTH,
Greetings
"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi Bart,

A appreciate your continued assistance on this topic.

First I will address our original approach...

You said...
basicly all fields keep the same values of the previous row and the row
selector in DataGrid doesn't change position.


There is a reason that this *does not* happen in my code. - I
pre-populate the controls with defaults. (come to think of it... I
don't set the comboBoxes to null at that time. - I don't know how to do
this ~ perhaps you can suggest something if this approach makes sense
to you)

What follows is a discription my current approach;

I *do* give default values to all checkBoxes. I did not show this in
the previous code because it was not relevant at the time... when I
create a new row I do the following;

User clicks NewRow button
1.) Data binding is suspend
2.) DataGrid is disabled
3.) Defaults are populated in the controls (see code below)

Then the user enters data and Clicks the Saves the (or the Cancels)
button. A save performs the following;

4.) The ID and documentation fields are assigned a GUID, date and the
username
5.) A dataRow is created, the row is populated with values from the
controls, the row is added to the dataset (see code below)
6.) The datasource updated
7.) Data bindings are resumed

[ 3.) from above ]
\\
Protected Overrides Sub PopulateControlDefaultsForNewRow()
' Primary Key GUID Value will be installed on save
Me.lblpkJobId.Text = "" ' Value will be installed on save
Me.txtJobNumber.Text = "" ' Required entry
Me.txtCustomerName.Text = "" ' Allow empty string
Me.txtJobDescription.Text = "" ' Allow empty string
Me.lblReferenceJobNumber.Text = "" ' (nullable) ~ auto populated

Me.txtShopPSI.Text = "" ' (nullable)
Me.cboSystemVoltage.Text = "" ' (nullable)
Me.cboSystemPhase.Text = "" ' (nullable)
Me.txtSystemAmps.Text = "" ' (nullable)
Me.chkHasCircuitBreakersYN.Checked = False

Me.chkAllProcessesAddedYN.Checked = False
Me.chkAllTasksAddedYN.Checked = False
Me.chkAllProcessesConfiguredYN.Checked = False
Me.chkApprovedYN.Checked = False
Me.chkCompletedYN.Checked = False
Me.chkIsMasterYN.Checked = False
Me.chkArchive.Checked = False

Me.txtUserNote.Text = "" ' Allow empty string
Me.txtCreatedOn.Text = "" ' Value will be installed on save
Me.txtCreatedBy.Text = "" ' Value will be installed on save
Me.txtEditedOn.Text = "" ' Value will be installed on save
Me.txtEditedBy.Text = "" ' Value will be installed on save
'jcrowversion
End Sub
//

[ 5.) from above ]
\\
Protected Overrides Sub InsertIntoDataset()

Dim row As DataRow = _dataSet1.Tables(_currentTable).NewRow

row("pkJobId") = Me.lblpkJobId.Text
row("JobNumber") = Me.txtJobNumber.Text
row("CustomerName") = Me.txtCustomerName.Text
row("JobDescription") = Me.txtJobDescription.Text

row("ReferenceJobNumber") = Me.lblReferenceJobNumber.Text

If Me.txtShopPSI.Text = "" Then ' DataType [Tinyint]
' If empty string then don't pass expression therefore Null
Else
row("ShopPsi") = Me.txtShopPSI.Text ' << the db stores this as short
or Int16
End If

If Me.cboSystemVoltage.SelectedIndex < 0 Then
'do nothing
Else
row("SystemVoltage") = Me.cboSystemVoltage.SelectedValue
End If

If Me.cboSystemPhase.SelectedIndex < 0 Then
'do nothing
Else
row("SystemPhase") = Me.cboSystemPhase.SelectedValue
End If

If Me.txtSystemAmps.Text = "" Then
' If empty string then don't pass expression therefore Null
Else
row("SystemAmps") = Me.txtSystemAmps.Text ' << the db stores this as
short or Int16
End If
row("HasCircuitBreakersYN") = Me.chkHasCircuitBreakersYN.Checked

row("AllProcessesAddedYN") = Me.chkAllProcessesAddedYN.Checked
row("AllTasksAddedYN") = Me.chkAllTasksAddedYN.Checked
row("AllProcessesConfiguredYN") =
Me.chkAllProcessesConfiguredYN.Checked
row("ApprovedYN") = Me.chkApprovedYN.Checked
row("CompletedYN") = Me.chkCompletedYN.Checked
row("IsMasterYN") = Me.chkIsMasterYN.Checked
row("Archive") = Me.chkArchive.Checked

row("jcUserNote") = Me.txtUserNote.Text
row("jcCreatedOn") = Me.txtCreatedOn.Text
row("jcCreatedBy") = Me.txtCreatedBy.Text
row("jcEditedOn") = Me.txtEditedOn.Text
row("jcEditedBy") = Me.txtEditedBy.Text
'jcrowversion

'Add this row to the DataSet
_dataSet1.Tables(_currentTable).Rows.Add(row)
End Sub
//

Based on the current approach what is the best solution? If I should
set the comboBoxes to null when I set the default values, how would I
to do this?

====================
Regarding your other suggestion, using NComboBox, how would I impliment
this approach?

After commenting out the other ComboBox references I tried the
following...

\\
Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

Friend WithEvents cboSystemPhase As NComboBox
Me.cboSystemPhase = New NComboBox

Me.grpSystemServices.Controls.Add(Me.cboSystemPhas e)

'cboSystemPhase
'
Me.cboSystemPhase.DropDownStyle = NComboBoxStyle.DropDownList
Me.cboSystemPhase.Location = New System.Drawing.Point(120, 72)
Me.cboSystemPhase.Name = "cboSystemPhase"
Me.cboSystemPhase.Size = New System.Drawing.Size(121, 21)
Me.cboSystemPhase.TabIndex = 5

End Sub
//

And

\\
Me.cboSystemPhase.DataBindings.Add("NSelectedValue ", _dt,
"SystemPhase")
//

But, how should it really done?

--
dbuchanan

Nov 21 '05 #17

P: n/a
Hi Bart,

I got option #1 to work, but I would like to use option #2 because you
suggest it is better.

Here is what I have done to try to get option #2 to work;
I commented out all option #1 code.
I commented out all references to my existing comboBox within the
Windows generatied code (I could have deleted the control)
I put your NComboBox code into its own class (note: I think part of
it is missing ~ see below)
I declared cboSystemPhase As NComboBox
I put my code that instantiates and defines the properties for
cboSystemPhase in the Public sub just after the InitializeComponent()

Here are the problems I encounter;
The DropDownStyle property does not recognize
NComboBoxStyle.DropdownList. It says: "Name 'NComboBoxStyle' is not
declared".

How to I correct this situation? My guess is that there is something
missing in the code for NComboBox? Here is my entire class;

\\
Public Class NComboBox
Inherits System.Windows.Forms.ComboBox

Public Property NSelectedValue() As Object
Get
Return SelectedValue
End Get
Set(ByVal Value As Object)
SelectedValue = Value
If (Value Is DBNull.Value And SelectedIndex <> -1) Then
SelectedValue = Value
End If
End Set
End Property

End Class
//

Here is my Public Sub New in the form;

\\
Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call

Me.cboSystemPhase = New NComboBox

Me.grpSystemServices.Controls.Add(Me.cboSystemPhas e)

'cboSystemPhase
Me.cboSystemPhase.DropDownStyle = NComboBoxStyle.DropDownList << The
problem line
Me.cboSystemPhase.Location = New System.Drawing.Point(120, 72)
Me.cboSystemPhase.Name = "cboSystemPhase"
Me.cboSystemPhase.Size = New System.Drawing.Size(121, 21)

End Sub
//

dbuchanan

Nov 21 '05 #18

P: n/a
Hi,
"dbuchanan" <db*********@hotmail.com> wrote in message >
news:11**********************@g47g2000cwa.googleg roups.com...Hi Bart,
I got option #1 to work, but I would like to use option #2 because you
suggest it is better.
Here is what I have done to try to get option #2 to work;
I commented out all option #1 code.
I commented out all references to my existing comboBox within the
Windows generatied code (I could have deleted the control)
I put your NComboBox code into its own class (note: I think part of
it is missing ~ see below)
I declared cboSystemPhase As NComboBox
I put my code that instantiates and defines the properties for
cboSystemPhase in the Public sub just after the InitializeComponent()

Here are the problems I encounter;
The DropDownStyle property does not recognize
NComboBoxStyle.DropdownList. It says: "Name 'NComboBoxStyle' is not
declared".

How to I correct this situation? My guess is that there is something
missing in the code for NComboBox? Here is my entire class;
[snip]
Here is my Public Sub New in the form; \\
Public Sub New()
MyBase.New() 'This call is required by the Windows Form Designer.
InitializeComponent()
Add any initialization after the InitializeComponent() call
Me.cboSystemPhase = New NComboBox
Me.grpSystemServices.Controls.Add(Me.cboSystemPha se)
'>cboSystemPhaseMe.cboSystemPhase.DropDownStyle = NComboBoxStyle.DropDownList << The
problem line
For most part it just works as a normal ComboBox, there is no
NComboBoxStyle, just ComboBoxStyle:

Private cboStystemPhase As NComboBox
'...
Me.cboSystemPhase.DropDownStyle = ComboBoxStyle.DropDownList
Also, consider that you can use the designer:
1. just place normal ComboBox's,
2. close the designer,
3. use edit find/replace to replace all System.Windows.Forms.ComboBox with
NComboBox,
* and be carefull not to replace ComboBoxStyle with NComboBoxStyle *
4. make sure it compiles,
5. re-open designer, it will accept the changes and not revert them.
HTH,
Greetings
Me.cboSystemPhase.Location = New System.Drawing.Point(120, 72)
Me.cboSystemPhase.Name = "cboSystemPhase"
Me.cboSystemPhase.Size = New System.Drawing.Size(121, 21)

End Sub

//

dbuchanan
Nov 21 '05 #19

P: n/a
Hi Bart,

I believe I have option #2 working, but Have a few questions.

1.) Do I need to replace SelectedValue with NSelectedValue in all
places or only when null is involved?

Example 1: Me.cboSystemVoltage.SelectedValue = DBNull.Value
Example 2: row("SystemVoltage") = Me.cboSystemVoltage.SelectedValue

2.) What is really happening in the class NComboBox

I don't understand what the first or second "SelectedValue = Value"
does
or what the block below does
\\
If (Value Is DBNull.Value And SelectedIndex <> -1) Then
SelectedValue = Value
End If
//

Could you briefly explain.

Thank you,
dbuchanan

Nov 21 '05 #20

P: n/a
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi Bart,

I believe I have option #2 working, but Have a few questions.

1.) Do I need to replace SelectedValue with NSelectedValue in all
places or only when null is involved?
You only need to use NSelectedValue when setting a DBNull.Value, but there
nothing wrong to always use it, to be consistent.
Example 1: Me.cboSystemVoltage.SelectedValue = DBNull.Value
Always Me.cboSystemVoltage.NSelectedValue.= DBNull.Value

Example 2: row("SystemVoltage") = Me.cboSystemVoltage.SelectedValue
Here you can use either, but be carefull because SelectedValue (or
NSelectedValue) can return Nothing, but the DataSet wants DBNull.Value:

If ( Me.cboSystemVoltage.NSelectedValue Is Nothing )
row("SystemVoltage") = DBNull.Value
Else
row("SystemVoltage") = Me.cboSystemVoltage.NSelectedValue
End If


2.) What is really happening in the class NComboBox

I don't understand what the first or second "SelectedValue = Value"
does
or what the block below does
The problem with the ComboBox is that you might need to call
SelectedValue=DBNull.Value or SelectedIndex=-1 twice to get it to accept the
null, this is needed when the previous selected item is not the first item
or not already null.

NComboBox inherits from ComboBox and it's adding a property NSelectedValue.
This property
1. sets the base (ComboBox) SelectedValue to the value passed in,
2. if the passed-in value is DBNull and the combobox didn't change to -1, it
will set it again.
hth,
greetings
\\
If (Value Is DBNull.Value And SelectedIndex <> -1) Then
SelectedValue = Value
End If
//

Could you briefly explain.

Thank you,
dbuchanan

Nov 21 '05 #21

P: n/a
Hi Bart and/or others,

(Bart are you still watching this thread?)

I am trying to use a checkbox with the threestate option set. I am
trying to bind (Checked, Unchecked, or Indeterminate (null)) to a
nullable bit column using a threestate Checkbox.

Bart wrote a solution for extending the comboBox to make a nullable
comboBox that worked very well - you/he refered to extending the
checkbox in the same way for a nullable Checkbox. I have been trying to
write this code without success.

I would be delighted with help with this.

Thank you,
dbuchanan
For reference the nullable combobox code; ~ one binds to
'NSelectedValue' instead of 'SelectedValue' so that a records with that
column null will be recognized as such in bound comboboxes on the form.
\\
Public Property NSelectedValue() As Object
Get
Return SelectedValue
End Get
Set(ByVal Value As Object)
SelectedValue = Value
If (Value Is DBNull.Value And SelectedIndex <> -1) Then
SelectedValue = Value
End If
End Set
End Property
//

Nov 21 '05 #22

P: n/a
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi Bart and/or others,

(Bart are you still watching this thread?)

I am trying to use a checkbox with the threestate option set. I am
trying to bind (Checked, Unchecked, or Indeterminate (null)) to a
nullable bit column using a threestate Checkbox.
You can use a normal checkbox, bind the CheckState property and handle parse
and format events of the Binding.

-- or -

You could use NCheckBox and bind to NCheckState:

Public Class NCheckBox
Inherits System.Windows.Forms.CheckBox

Private CheckedValue As Object = True
Private UncheckedValue As Object = False
Private IndeterminateValue As Object = DBNull.Value

Public Sub New()
ThreeState = True
End Sub

Public Event NCheckStateChanged As EventHandler

Public Property NCheckState() As Object
Get
If (CheckState = CheckState.Indeterminate) Then
Return IndeterminateValue
ElseIf (CheckState = CheckState.Checked) Then
Return CheckedValue
Else
Return UncheckedValue
End If
End Get
Set(ByVal Value As Object)
If (Equals(Value, IndeterminateValue)) Then
CheckState = CheckState.Indeterminate
ElseIf (Equals(Value, CheckedValue)) Then
CheckState = CheckState.Checked
ElseIf (Equals(Value, UncheckedValue)) Then
CheckState = CheckState.Unchecked
Else
Throw New Exception("Invalid value set")
End If
End Set
End Property

Private Sub NCheckBox_CheckStateChanged( _
ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.CheckStateChanged
RaiseEvent NCheckStateChanged(Me, EventArgs.Empty)
End Sub
End Class
HTH,
Greetings


Bart wrote a solution for extending the comboBox to make a nullable
comboBox that worked very well - you/he refered to extending the
checkbox in the same way for a nullable Checkbox. I have been trying to
write this code without success.

I would be delighted with help with this.

Thank you,
dbuchanan
For reference the nullable combobox code; ~ one binds to
'NSelectedValue' instead of 'SelectedValue' so that a records with that
column null will be recognized as such in bound comboboxes on the form.
\\
Public Property NSelectedValue() As Object
Get
Return SelectedValue
End Get
Set(ByVal Value As Object)
SelectedValue = Value
If (Value Is DBNull.Value And SelectedIndex <> -1) Then
SelectedValue = Value
End If
End Set
End Property
//

Nov 21 '05 #23

P: n/a
Hi Bart,

I have applied the code you suggested. I am using "Button" for the
appearance property and am using the following code to change the text
property.

It appears that "CheckState.Indeterminate" is not working because "N/A"
only appears when the form first opens.

Here is the method that controls the text property
\\
Private Sub chkSensorStyleIsPNP_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
chkSensorStyleIsPNP.CheckedChanged
Select Case chkSensorStyleIsPNP.CheckState
Case CheckState.Checked
chkSensorStyleIsPNP.Text = "PNP"
Case CheckState.Indeterminate
chkSensorStyleIsPNP.Text = "N/A"
Case CheckState.Unchecked
chkSensorStyleIsPNP.Text = "NPN"
End Select
End Sub
//

What am I doing wrong?

Thank you,
dbuchanan

-----------------------
Additional info and settings follow;

Here is how it is called in the components area
\\
Friend WithEvents chkSensorStyleIsPNP As CLIP.NCheckBox

Me.chkSensorStyleIsPNP = New CLIP.NCheckBox
//
Here it is the Initialize area
\\
'chkSensorStyleIsPNP
'
Me.chkSensorStyleIsPNP.Appearance =
System.Windows.Forms.Appearance.Button
Me.chkSensorStyleIsPNP.Checked = True
Me.chkSensorStyleIsPNP.CheckState =
System.Windows.Forms.CheckState.Indeterminate
Me.chkSensorStyleIsPNP.Location = New System.Drawing.Point(112, 48)
Me.chkSensorStyleIsPNP.Name = "chkSensorStyleIsPNP"
Me.chkSensorStyleIsPNP.NCheckState =
CType(resources.GetObject("chkSensorStyleIsPNP.NCh eckState"), Object)
Me.chkSensorStyleIsPNP.TabIndex = 77
Me.chkSensorStyleIsPNP.Text = "N/A"
Me.chkSensorStyleIsPNP.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
Me.chkSensorStyleIsPNP.ThreeState = True
Me.ToolTip1.SetToolTip(Me.chkSensorStyleIsPNP, "Please click to select
proper value.")
//
Here is the databinding
\\
Me.chkSensorStyleIsPNP.DataBindings.Add("NChecksta te", _dt, "cmBit06")
//

Nov 21 '05 #24

P: n/a
I thought it would be appropriate to ask about this within this discussion.
I'm new to discussion groups - so let me know if this isn't the best way to
continue this topic.

Thanks for the solutions for combobox binding. The problem I'm having now is
that the HasChanges property of my dataset gets set to True when the
SelectedIndex property is set to -1 for Null Values of the combobox.

Any thoughts on the relationship between the dataset HasChanges property and
forcing the value of SelectedIndex?

Does this all go away in the new version of VS?

Thanks for any help on this.
"Bart Mermuys" wrote:
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi Bart and/or others,

(Bart are you still watching this thread?)

I am trying to use a checkbox with the threestate option set. I am
trying to bind (Checked, Unchecked, or Indeterminate (null)) to a
nullable bit column using a threestate Checkbox.


You can use a normal checkbox, bind the CheckState property and handle parse
and format events of the Binding.

-- or -

You could use NCheckBox and bind to NCheckState:

Public Class NCheckBox
Inherits System.Windows.Forms.CheckBox

Private CheckedValue As Object = True
Private UncheckedValue As Object = False
Private IndeterminateValue As Object = DBNull.Value

Public Sub New()
ThreeState = True
End Sub

Public Event NCheckStateChanged As EventHandler

Public Property NCheckState() As Object
Get
If (CheckState = CheckState.Indeterminate) Then
Return IndeterminateValue
ElseIf (CheckState = CheckState.Checked) Then
Return CheckedValue
Else
Return UncheckedValue
End If
End Get
Set(ByVal Value As Object)
If (Equals(Value, IndeterminateValue)) Then
CheckState = CheckState.Indeterminate
ElseIf (Equals(Value, CheckedValue)) Then
CheckState = CheckState.Checked
ElseIf (Equals(Value, UncheckedValue)) Then
CheckState = CheckState.Unchecked
Else
Throw New Exception("Invalid value set")
End If
End Set
End Property

Private Sub NCheckBox_CheckStateChanged( _
ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.CheckStateChanged
RaiseEvent NCheckStateChanged(Me, EventArgs.Empty)
End Sub
End Class
HTH,
Greetings


Bart wrote a solution for extending the comboBox to make a nullable
comboBox that worked very well - you/he refered to extending the
checkbox in the same way for a nullable Checkbox. I have been trying to
write this code without success.

I would be delighted with help with this.

Thank you,
dbuchanan
For reference the nullable combobox code; ~ one binds to
'NSelectedValue' instead of 'SelectedValue' so that a records with that
column null will be recognized as such in bound comboboxes on the form.
\\
Public Property NSelectedValue() As Object
Get
Return SelectedValue
End Get
Set(ByVal Value As Object)
SelectedValue = Value
If (Value Is DBNull.Value And SelectedIndex <> -1) Then
SelectedValue = Value
End If
End Set
End Property
//


Nov 21 '05 #25

P: n/a
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11********************@g47g2000cwa.googlegrou ps.com...
Hi Bart,

I have applied the code you suggested. I am using "Button" for the
appearance property and am using the following code to change the text
property.

It appears that "CheckState.Indeterminate" is not working because "N/A"
only appears when the form first opens.

Here is the method that controls the text property
\\
Private Sub chkSensorStyleIsPNP_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
chkSensorStyleIsPNP.CheckedChanged
Don't handle chkSensorStyleIsPNP.CheckedChanged, CheckedChanged applies to
the Checked property which indeed does not support threestate.

Since you are checking CheckState you should be handling
chkSensorStyleIsPNP.CheckStateChanged (which does support threestate)

HTH,
Greetings
Select Case chkSensorStyleIsPNP.CheckState
Case CheckState.Checked
chkSensorStyleIsPNP.Text = "PNP"
Case CheckState.Indeterminate
chkSensorStyleIsPNP.Text = "N/A"
Case CheckState.Unchecked
chkSensorStyleIsPNP.Text = "NPN"
End Select
End Sub
//

What am I doing wrong?

Thank you,
dbuchanan

-----------------------
Additional info and settings follow;

Here is how it is called in the components area
\\
Friend WithEvents chkSensorStyleIsPNP As CLIP.NCheckBox

Me.chkSensorStyleIsPNP = New CLIP.NCheckBox
//
Here it is the Initialize area
\\
'chkSensorStyleIsPNP
'
Me.chkSensorStyleIsPNP.Appearance =
System.Windows.Forms.Appearance.Button
Me.chkSensorStyleIsPNP.Checked = True
Me.chkSensorStyleIsPNP.CheckState =
System.Windows.Forms.CheckState.Indeterminate
Me.chkSensorStyleIsPNP.Location = New System.Drawing.Point(112, 48)
Me.chkSensorStyleIsPNP.Name = "chkSensorStyleIsPNP"
Me.chkSensorStyleIsPNP.NCheckState =
CType(resources.GetObject("chkSensorStyleIsPNP.NCh eckState"), Object)
Me.chkSensorStyleIsPNP.TabIndex = 77
Me.chkSensorStyleIsPNP.Text = "N/A"
Me.chkSensorStyleIsPNP.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
Me.chkSensorStyleIsPNP.ThreeState = True
Me.ToolTip1.SetToolTip(Me.chkSensorStyleIsPNP, "Please click to select
proper value.")
//
Here is the databinding
\\
Me.chkSensorStyleIsPNP.DataBindings.Add("NChecksta te", _dt, "cmBit06")
//

Nov 21 '05 #26

P: n/a

Hi dbuchanan & earnest,

I have been thinking about a better aproach for the ComboBox null problem,
solutions so far always corrected the ComboBox after it went to an incorrect
state (first item selected instead of cleared text). This seems to work but
as Earnest pointed out it may cause phantom changes in a datasource bound to
SelectedValue.

I've come up with a new NComboBox posted at the bottom which can be used and
bound like any other ComboBox and it deals with the null problem at the root
causing no phantom changes. This workaround fixes both SelectedIndex and
SelectedValue by overriding OnSelectedIndexChanged where the bug is located.
It also adds the abillity for the user to press del or backspace to select
nothing.

I don't believe there is another way to do this without inheriting from a
ComboBox like NComboBox.

The problem with ComboBox and Null value is fixed in .NET2.0.

HTH,
Greetings
Imports System.Reflection

Public Class NComboBox
Inherits System.Windows.Forms.ComboBox

Shared EVENT_SELIDXCHANGED As Object

Shared Sub New()
EVENT_SELIDXCHANGED = GetType(ComboBox).GetField( _
"EVENT_SELECTEDINDEXCHANGED", _
BindingFlags.NonPublic Or BindingFlags.Static).GetValue(Nothing)
End Sub

Protected Overrides Sub OnSelectedIndexChanged(ByVal e As EventArgs)
' fire selectedvalue changed
OnSelectedValueChanged(EventArgs.Empty)

' fire selectedindex changed
Dim selEvent As EventHandler = Events(EVENT_SELIDXCHANGED)
If (Not selEvent Is Nothing) Then selEvent(Me, e)

' fix, only update currencymanager if index<>-1
If ((Not MyBase.DataManager Is Nothing) And _
(MyBase.DataManager.Position <> SelectedIndex) And _
(SelectedIndex <> -1)) Then
MyBase.DataManager.Position = SelectedIndex
End If
End Sub

Private Sub NComboBox_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles MyBase.KeyDown

If (e.KeyCode = Keys.Delete) Or (e.KeyCode = Keys.Back) Then
SelectedIndex = -1
End If
End Sub

End Class

Nov 21 '05 #27

P: n/a
Hi,

"Earnest" <Ea*****@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
I thought it would be appropriate to ask about this within this discussion.
I'm new to discussion groups - so let me know if this isn't the best way
to
continue this topic.
See new subthread i started.

hth,
greetings

Thanks for the solutions for combobox binding. The problem I'm having now
is
that the HasChanges property of my dataset gets set to True when the
SelectedIndex property is set to -1 for Null Values of the combobox.

Any thoughts on the relationship between the dataset HasChanges property
and
forcing the value of SelectedIndex?

Does this all go away in the new version of VS?

Thanks for any help on this.
"Bart Mermuys" wrote:
Hi,

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
> Hi Bart and/or others,
>
> (Bart are you still watching this thread?)
>
> I am trying to use a checkbox with the threestate option set. I am
> trying to bind (Checked, Unchecked, or Indeterminate (null)) to a
> nullable bit column using a threestate Checkbox.


You can use a normal checkbox, bind the CheckState property and handle
parse
and format events of the Binding.

-- or -

You could use NCheckBox and bind to NCheckState:

Public Class NCheckBox
Inherits System.Windows.Forms.CheckBox

Private CheckedValue As Object = True
Private UncheckedValue As Object = False
Private IndeterminateValue As Object = DBNull.Value

Public Sub New()
ThreeState = True
End Sub

Public Event NCheckStateChanged As EventHandler

Public Property NCheckState() As Object
Get
If (CheckState = CheckState.Indeterminate) Then
Return IndeterminateValue
ElseIf (CheckState = CheckState.Checked) Then
Return CheckedValue
Else
Return UncheckedValue
End If
End Get
Set(ByVal Value As Object)
If (Equals(Value, IndeterminateValue)) Then
CheckState = CheckState.Indeterminate
ElseIf (Equals(Value, CheckedValue)) Then
CheckState = CheckState.Checked
ElseIf (Equals(Value, UncheckedValue)) Then
CheckState = CheckState.Unchecked
Else
Throw New Exception("Invalid value set")
End If
End Set
End Property

Private Sub NCheckBox_CheckStateChanged( _
ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.CheckStateChanged
RaiseEvent NCheckStateChanged(Me, EventArgs.Empty)
End Sub
End Class
HTH,
Greetings

>
> Bart wrote a solution for extending the comboBox to make a nullable
> comboBox that worked very well - you/he refered to extending the
> checkbox in the same way for a nullable Checkbox. I have been trying to
> write this code without success.
>
> I would be delighted with help with this.
>
> Thank you,
> dbuchanan
>
>
> For reference the nullable combobox code; ~ one binds to
> 'NSelectedValue' instead of 'SelectedValue' so that a records with that
> column null will be recognized as such in bound comboboxes on the form.
> \\
> Public Property NSelectedValue() As Object
> Get
> Return SelectedValue
> End Get
> Set(ByVal Value As Object)
> SelectedValue = Value
> If (Value Is DBNull.Value And SelectedIndex <> -1) Then
> SelectedValue = Value
> End If
> End Set
> End Property
> //
>


Nov 21 '05 #28

P: n/a
Hi Bart,

My Newbieness is showing...

I created a class in my project called NComboBox. I think I had to add an
Imports System.Reflection to get BindingFlags reference errors corrected.

This is basic stuff now - I bet this will work - how do you use the Modified
combobox? Can it be added somehow to the Toolbox and dropped onto a form or
can you only use it in code?

Thanks for all your help with this. It's almost there!

Best,

"Bart Mermuys" wrote:

Hi dbuchanan & earnest,

I have been thinking about a better aproach for the ComboBox null problem,
solutions so far always corrected the ComboBox after it went to an incorrect
state (first item selected instead of cleared text). This seems to work but
as Earnest pointed out it may cause phantom changes in a datasource bound to
SelectedValue.

I've come up with a new NComboBox posted at the bottom which can be used and
bound like any other ComboBox and it deals with the null problem at the root
causing no phantom changes. This workaround fixes both SelectedIndex and
SelectedValue by overriding OnSelectedIndexChanged where the bug is located.
It also adds the abillity for the user to press del or backspace to select
nothing.

I don't believe there is another way to do this without inheriting from a
ComboBox like NComboBox.

The problem with ComboBox and Null value is fixed in .NET2.0.

HTH,
Greetings
Imports System.Reflection

Public Class NComboBox
Inherits System.Windows.Forms.ComboBox

Shared EVENT_SELIDXCHANGED As Object

Shared Sub New()
EVENT_SELIDXCHANGED = GetType(ComboBox).GetField( _
"EVENT_SELECTEDINDEXCHANGED", _
BindingFlags.NonPublic Or BindingFlags.Static).GetValue(Nothing)
End Sub

Protected Overrides Sub OnSelectedIndexChanged(ByVal e As EventArgs)
' fire selectedvalue changed
OnSelectedValueChanged(EventArgs.Empty)

' fire selectedindex changed
Dim selEvent As EventHandler = Events(EVENT_SELIDXCHANGED)
If (Not selEvent Is Nothing) Then selEvent(Me, e)

' fix, only update currencymanager if index<>-1
If ((Not MyBase.DataManager Is Nothing) And _
(MyBase.DataManager.Position <> SelectedIndex) And _
(SelectedIndex <> -1)) Then
MyBase.DataManager.Position = SelectedIndex
End If
End Sub

Private Sub NComboBox_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles MyBase.KeyDown

If (e.KeyCode = Keys.Delete) Or (e.KeyCode = Keys.Back) Then
SelectedIndex = -1
End If
End Sub

End Class

Nov 21 '05 #29

P: n/a
Hi,
"Earnest" <Ea*****@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
Hi Bart,

My Newbieness is showing...

I created a class in my project called NComboBox. I think I had to add an
Imports System.Reflection to get BindingFlags reference errors corrected.
Yes, it was in the code i posted.

This is basic stuff now - I bet this will work - how do you use the
Modified
combobox? Can it be added somehow to the Toolbox and dropped onto a form
or
can you only use it in code?
Well, you can always use it from code and it should show up on the Toolbox
just like that, but it doesn't. The thing that seems to work for me is to
start by creating a user control:

- select all code from your NComboBox class and copy it (clipboard)
- delete your current NComboBox class
- Project -> Add User Control -> NComboBox
- Whipe out all code in the new usercontrol
- paste the NComboBox code
- compile

Now, NComboBox should be on the Toolbox under My User Controls.

hth,
greetings


Thanks for all your help with this. It's almost there!

Best,

"Bart Mermuys" wrote:

Hi dbuchanan & earnest,

I have been thinking about a better aproach for the ComboBox null
problem,
solutions so far always corrected the ComboBox after it went to an
incorrect
state (first item selected instead of cleared text). This seems to work
but
as Earnest pointed out it may cause phantom changes in a datasource bound
to
SelectedValue.

I've come up with a new NComboBox posted at the bottom which can be used
and
bound like any other ComboBox and it deals with the null problem at the
root
causing no phantom changes. This workaround fixes both SelectedIndex and
SelectedValue by overriding OnSelectedIndexChanged where the bug is
located.
It also adds the abillity for the user to press del or backspace to
select
nothing.

I don't believe there is another way to do this without inheriting from a
ComboBox like NComboBox.

The problem with ComboBox and Null value is fixed in .NET2.0.

HTH,
Greetings
Imports System.Reflection

Public Class NComboBox
Inherits System.Windows.Forms.ComboBox

Shared EVENT_SELIDXCHANGED As Object

Shared Sub New()
EVENT_SELIDXCHANGED = GetType(ComboBox).GetField( _
"EVENT_SELECTEDINDEXCHANGED", _
BindingFlags.NonPublic Or
BindingFlags.Static).GetValue(Nothing)
End Sub

Protected Overrides Sub OnSelectedIndexChanged(ByVal e As EventArgs)
' fire selectedvalue changed
OnSelectedValueChanged(EventArgs.Empty)

' fire selectedindex changed
Dim selEvent As EventHandler = Events(EVENT_SELIDXCHANGED)
If (Not selEvent Is Nothing) Then selEvent(Me, e)

' fix, only update currencymanager if index<>-1
If ((Not MyBase.DataManager Is Nothing) And _
(MyBase.DataManager.Position <> SelectedIndex) And _
(SelectedIndex <> -1)) Then
MyBase.DataManager.Position = SelectedIndex
End If
End Sub

Private Sub NComboBox_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles MyBase.KeyDown

If (e.KeyCode = Keys.Delete) Or (e.KeyCode = Keys.Back) Then
SelectedIndex = -1
End If
End Sub

End Class

Nov 21 '05 #30

P: n/a
Hi Bart,

Yes, er, you did include the imports... sorry about that.

Thanks very much. I've been trying to track this problem down for weeks. I'm
an MSAccess VBA programmer transitioning to VB.Net. It amazes me how much
doesn't work in .Net or requires levels of proficiency far deeper than what
was required in Access. It's like a joke from an old movie: (Nashville)

"Did you ever ask a lawyer the time of day? He told you how to build a watch
didn't he..."

So far in .Net you really need to know how to build a watch instead of
knowing how to tell time.

Enough whinning. Thanks very much for the help. I really appreciate it.

Best Wishes
"Bart Mermuys" wrote:
Hi,
"Earnest" <Ea*****@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
Hi Bart,

My Newbieness is showing...

I created a class in my project called NComboBox. I think I had to add an
Imports System.Reflection to get BindingFlags reference errors corrected.


Yes, it was in the code i posted.

This is basic stuff now - I bet this will work - how do you use the
Modified
combobox? Can it be added somehow to the Toolbox and dropped onto a form
or
can you only use it in code?


Well, you can always use it from code and it should show up on the Toolbox
just like that, but it doesn't. The thing that seems to work for me is to
start by creating a user control:

- select all code from your NComboBox class and copy it (clipboard)
- delete your current NComboBox class
- Project -> Add User Control -> NComboBox
- Whipe out all code in the new usercontrol
- paste the NComboBox code
- compile

Now, NComboBox should be on the Toolbox under My User Controls.

hth,
greetings


Thanks for all your help with this. It's almost there!

Best,

"Bart Mermuys" wrote:

Hi dbuchanan & earnest,

I have been thinking about a better aproach for the ComboBox null
problem,
solutions so far always corrected the ComboBox after it went to an
incorrect
state (first item selected instead of cleared text). This seems to work
but
as Earnest pointed out it may cause phantom changes in a datasource bound
to
SelectedValue.

I've come up with a new NComboBox posted at the bottom which can be used
and
bound like any other ComboBox and it deals with the null problem at the
root
causing no phantom changes. This workaround fixes both SelectedIndex and
SelectedValue by overriding OnSelectedIndexChanged where the bug is
located.
It also adds the abillity for the user to press del or backspace to
select
nothing.

I don't believe there is another way to do this without inheriting from a
ComboBox like NComboBox.

The problem with ComboBox and Null value is fixed in .NET2.0.

HTH,
Greetings
Imports System.Reflection

Public Class NComboBox
Inherits System.Windows.Forms.ComboBox

Shared EVENT_SELIDXCHANGED As Object

Shared Sub New()
EVENT_SELIDXCHANGED = GetType(ComboBox).GetField( _
"EVENT_SELECTEDINDEXCHANGED", _
BindingFlags.NonPublic Or
BindingFlags.Static).GetValue(Nothing)
End Sub

Protected Overrides Sub OnSelectedIndexChanged(ByVal e As EventArgs)
' fire selectedvalue changed
OnSelectedValueChanged(EventArgs.Empty)

' fire selectedindex changed
Dim selEvent As EventHandler = Events(EVENT_SELIDXCHANGED)
If (Not selEvent Is Nothing) Then selEvent(Me, e)

' fix, only update currencymanager if index<>-1
If ((Not MyBase.DataManager Is Nothing) And _
(MyBase.DataManager.Position <> SelectedIndex) And _
(SelectedIndex <> -1)) Then
MyBase.DataManager.Position = SelectedIndex
End If
End Sub

Private Sub NComboBox_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles MyBase.KeyDown

If (e.KeyCode = Keys.Delete) Or (e.KeyCode = Keys.Back) Then
SelectedIndex = -1
End If
End Sub

End Class


Nov 21 '05 #31

This discussion thread is closed

Replies have been disabled for this discussion.