T
thomasp
I know this is a vague question, but I am not sure what information to give.
I am using VB2005 beta and the datagridview is pulling data from one of
three tables in an Access database. For some reason when I edit the feilds
that I have not set as readonly, the changes do not get written to the
database. I have the code that loads the datagridview posted below. Thanks
for any suggestions.
Thanks,
Thomas
Private Sub frmViewTables_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Variable used to track if the form is loading
'it will be used to keep some events from running
'when the form is loading
bolIsLoading = True
Me.Cursor = Cursors.WaitCursor
Me.Refresh()
'Set the form up based on which Table will be displayed
Select Case intDataTable
Case Is = 1
Me.LCMRTableAdapter.Fill(Me.TAMDataSet.LCMR)
Me.DataGridView1.DataSource = Me.TAMDataSet.LCMR
Me.Text = "LCMR DataTable"
Case Is = 2
Me.Q36TableAdapter.Fill(Me.TAMDataSet.Q36)
Me.DataGridView1.DataSource = Me.TAMDataSet.Q36
Me.Text = "Q36 DataTable"
Case Is = 3
Me.UTAMSTableAdapter.Fill(Me.TAMDataSet.UTAMS)
Me.DataGridView1.DataSource = Me.TAMDataSet.UTAMS
Me.Text = "UTAMS DataTable"
End Select
'Set up the header row
With DataGridView1.ColumnHeadersDefaultCellStyle
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(DataGridView1.Font, FontStyle.Bold)
End With
' Create a new cell style.
Dim style As New DataGridViewCellStyle
With style
.BackColor = Color.Beige
'.ForeColor = Color.Brown
End With
With DataGridView1
.EditMode = DataGridViewEditMode.EditOnEnter
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCells
.AutoSizeColumnsMode = _
DataGridViewAutoSizeColumnsMode.DisplayedCells
.ColumnHeadersBorderStyle = _
DataGridViewHeaderBorderStyle.Raised
.ColumnHeadersVisible = True
.CellBorderStyle = _
DataGridViewCellBorderStyle.Single
.GridColor = SystemColors.ActiveBorder
.AllowUserToAddRows = False
.AllowUserToOrderColumns = True
.AllowUserToResizeColumns = True
.BackgroundColor = Color.Honeydew
.Columns("DTG").DefaultCellStyle.Format = "dd-MMM-yy HH:mm:ss"
.Columns("Distance").DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleRight
.Columns("ID").ReadOnly = True
Select Case intDataTable
Case Is = 1
.Columns("Distance").ReadOnly = True
.Columns("Direction").ReadOnly = True
.Columns("RDistance").ReadOnly = True
.Columns("RDirection").ReadOnly = True
Case Is = 2
.Columns("Distance").ReadOnly = True
.Columns("Direction").ReadOnly = True
.Columns("RDistance").ReadOnly = True
.Columns("RDirection").ReadOnly = True
.Columns("Db").ReadOnly = True
.Columns("Velocity").ReadOnly = True
Case Is = 3
End Select
End With
' Apply the style as the default cell style.
DataGridView1.AlternatingRowsDefaultCellStyle = style
Me.Cursor = Cursors.Default
Me.Refresh()
'form has finished loading
bolIsLoading = False
End Sub
I am using VB2005 beta and the datagridview is pulling data from one of
three tables in an Access database. For some reason when I edit the feilds
that I have not set as readonly, the changes do not get written to the
database. I have the code that loads the datagridview posted below. Thanks
for any suggestions.
Thanks,
Thomas
Private Sub frmViewTables_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Variable used to track if the form is loading
'it will be used to keep some events from running
'when the form is loading
bolIsLoading = True
Me.Cursor = Cursors.WaitCursor
Me.Refresh()
'Set the form up based on which Table will be displayed
Select Case intDataTable
Case Is = 1
Me.LCMRTableAdapter.Fill(Me.TAMDataSet.LCMR)
Me.DataGridView1.DataSource = Me.TAMDataSet.LCMR
Me.Text = "LCMR DataTable"
Case Is = 2
Me.Q36TableAdapter.Fill(Me.TAMDataSet.Q36)
Me.DataGridView1.DataSource = Me.TAMDataSet.Q36
Me.Text = "Q36 DataTable"
Case Is = 3
Me.UTAMSTableAdapter.Fill(Me.TAMDataSet.UTAMS)
Me.DataGridView1.DataSource = Me.TAMDataSet.UTAMS
Me.Text = "UTAMS DataTable"
End Select
'Set up the header row
With DataGridView1.ColumnHeadersDefaultCellStyle
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(DataGridView1.Font, FontStyle.Bold)
End With
' Create a new cell style.
Dim style As New DataGridViewCellStyle
With style
.BackColor = Color.Beige
'.ForeColor = Color.Brown
End With
With DataGridView1
.EditMode = DataGridViewEditMode.EditOnEnter
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCells
.AutoSizeColumnsMode = _
DataGridViewAutoSizeColumnsMode.DisplayedCells
.ColumnHeadersBorderStyle = _
DataGridViewHeaderBorderStyle.Raised
.ColumnHeadersVisible = True
.CellBorderStyle = _
DataGridViewCellBorderStyle.Single
.GridColor = SystemColors.ActiveBorder
.AllowUserToAddRows = False
.AllowUserToOrderColumns = True
.AllowUserToResizeColumns = True
.BackgroundColor = Color.Honeydew
.Columns("DTG").DefaultCellStyle.Format = "dd-MMM-yy HH:mm:ss"
.Columns("Distance").DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleRight
.Columns("ID").ReadOnly = True
Select Case intDataTable
Case Is = 1
.Columns("Distance").ReadOnly = True
.Columns("Direction").ReadOnly = True
.Columns("RDistance").ReadOnly = True
.Columns("RDirection").ReadOnly = True
Case Is = 2
.Columns("Distance").ReadOnly = True
.Columns("Direction").ReadOnly = True
.Columns("RDistance").ReadOnly = True
.Columns("RDirection").ReadOnly = True
.Columns("Db").ReadOnly = True
.Columns("Velocity").ReadOnly = True
Case Is = 3
End Select
End With
' Apply the style as the default cell style.
DataGridView1.AlternatingRowsDefaultCellStyle = style
Me.Cursor = Cursors.Default
Me.Refresh()
'form has finished loading
bolIsLoading = False
End Sub