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
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access 3 11734
Thomas,
I see a lot of non relevant code for the update. However is there some code
to update as well?
Cor
<th*****@msala.net> schreef in bericht
news:43***********************@news.newsdemon.com. .. 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
-- Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ------->>>>>>http://www.NewsDemon.com<<<<<<------ Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Well, that may be my problem. I thought that as long as the field was not
set to readonly and I had editonenter set that VB would handle the updating.
I was not aware that I needed to add code for the update to occur. Please
point me in the direction of what code I need to have the datagridview
update the database.
Thanks,
Thomas
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Thomas,
This is absolute not the right sample, however it shows you at least how to
update.
Better is of course to use an update button for an update. Than you have as
well to check for errors as by instance concurrency errors (that is if
somebody made changes in the maintime). However in my opinion is it nice to
see the basic. (The absolute most simple update version as there is, is at
the bottom).
This sample does a little bit it in the way as you thought it was working. http://www.windowsformsdatagridhelp....7-5595f8147624
I hope this helps,
Cor
<th*****@msala.net> schreef in bericht
news:43**********************@news.newsdemon.com.. . Well, that may be my problem. I thought that as long as the field was not set to readonly and I had editonenter set that VB would handle the updating. I was not aware that I needed to add code for the update to occur. Please point me in the direction of what code I need to have the datagridview update the database.
Thanks,
Thomas
-- Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ------->>>>>>http://www.NewsDemon.com<<<<<<------ Unlimited Access, Anonymous Accounts, Uncensored Broadband Access This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Henok Girma |
last post by:
Hello Gurus,
I want to save the state of an unbound DataGridView on my Windows Form
application to an XML file so i can later load it back..
Basically, on my form I have a DataGridView, it's got...
|
by: TNSFED |
last post by:
I have a dilemma when trying to delete a row from the DataGridView. Here
is a sample of my code:
private void dgv_EQUPS_UserDeletingRow(object sender,
DataGridViewRowCancelEventArgs e)
{...
|
by: bob |
last post by:
Can anyone tell me the best way to update a dataset while it is being
edited/viewed in the DataGridView control? Is this something that
should be inserted into one of the grid's events? or should...
|
by: Kevin |
last post by:
I've been searching forever for examples of saving data changes in a
DataGridView. There's all kinds of examples, but none really show how
to save changes. Someone please help me.
I have a...
|
by: Hexman |
last post by:
Hello All,
I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it.
-------------------------------
1) Add a cb to the dgv,...
|
by: Martin |
last post by:
Hi all,
This is the situation...
DatagridView Control with datasource set to datatable.
I want the user to be able to delete x number of rows by selecting a row
with mouse then clicking a...
|
by: =?Utf-8?B?TG9zdEluTUQ=?= |
last post by:
Hi All :)
I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView.
True DBGrid has a MultipleLines property that controls whether individual
records span multiple lines. Is...
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
On a form - I have a datagridview which is docked to the entire form. The
datagridview allows users to Delete and/or Add Rows. On the Form_Load event
I Fill the datagridview source table with a...
|
by: nev |
last post by:
Happy Easter to all!
I have a problem with a datagridview. I placed code in a button click event as follows:
dim dtt as datatable = dataset.employees.copy
dtt.DefaultView.RowFilter = "='" &...
|
by: Bill Schanks |
last post by:
VB.NET 2005
SQL Server 2000
I have a datagridview that users will update. When there are only a
few records the update is fine. However when they update 100-200 of
the rows the udpate can take...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |