473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need help with vb.net and datagrid


I need help to format the column and detect any change on the datagrid.

My source code is:

dim da as SqlDataAdapter
dim ds as DataSet
dim dtSource as DataTable

dim conn as SQLConnection = New SQLConnection(......)

da = New SQLDataAdapter ("Select field1, field2, from tablename",conn)
ds = New dataset

da.fill(ds,"tablename")

dtSource = ds.Tables("tablename")

datagrid1.datasource = dtsource
'===== So far everything up to this point is ok.
I try changing the column with for field 1 by using
PreferredColumnWidth but it doesn't work.

I can changed the datagrid but it wont update the table. How can I
detect if there is a new update so I can run datagrid1.update

Appreciate any help.

Thanks
Roel

Nov 22 '05 #1
2 1432
Roel,

You can visit our website and search for "styles" than you get a lot of
samples

http://www.windowsformsdatagridhelp.com/default.aspx

If the solution for your problem is not there, than let us know (using this
newsgroup or the newsgroup)
microsoft.public.dotnet.languages.vb
(In that is Ken as well active).

However, I hope that it helps direct.

Cor
Nov 22 '05 #2
Cor

Your website was a good source of information and I was able to figure
out what I need.

I found this code on you site but I couldn't make it work. This is
when the datagrid is loaded and you press the delete key on a row.
AddHandler ds.Tables(0).RowDeleting, New
DataRowChangeEventHandler(AddressOf Row_Deleting)
'AddHandler ds.Tables(0).RowDeleted, New
DataRowChangeEventHandler(AddressOf Row_Deleting)

Private Sub Row_Deleting(ByVal sender As Object, ByVal e As
DataRowChangeEventArgs)

If MessageBox.Show("Delete row? ", "",
MessageBoxButtons.OKCancel) = DialogResult.Cancel Then
e.Row.RejectChanges()
'ds.RejectChanges()
Else
'get the staff id
MsgBox(e.Row.ItemArray(0))

End If
End Sub

It doesn't matter if I click Ok or Cancel, the row is deleted from the
datagrid. How can I put it back on the datagrid with out reloading
everything?

Thanks for your help.
Roel

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
0
by: MrNobody | last post by:
I am desperately in need of some help to get a summary row for my DataGrid. A summary row is just a row always on the bottom which has totals for certain columns. I have been able to find...
1
by: ericm1155 | last post by:
I am trying to display some information from a database in a form that displays one record per line. When the user clicks anywhere on a line, that record is highlighted and selected, and my program...
5
by: Luis E Valencia | last post by:
I need a link on a datagrid, the link must have fields of the database Like this acciones.aspx?iddireccion=1&idindicador=4 Thanks
1
by: Jennyfer J Barco | last post by:
Hello again I have a datagrid and I'm showing many records. I need 2 things: I need that everytime they scroll down, the header stays lock so the user can see it all the time. I need to scroll...
1
by: Anna | last post by:
I have a simple DataGrid that displays a list of characteristics and allows you to edit a description for each characteristic. The query that feeds this involves a join, as the characteristics and...
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
21
by: coleenholley | last post by:
I've been trying since last Friday to get an answer on how to get a SPECIFIC row.cell value from a datagrid. I've had plenty of suggestions, but nothing works to get the value from a SPECIFIC Row...
3
by: Larry Woods | last post by:
I have a datagrid that is carrying all fields of a record...except one. Now I want to update the underlying database via a dataadapter. The update is working but the field that is "left out" is...
0
by: Familjen Karlsson | last post by:
Hi I have downloaded some code and tried it and nothing happens with the datagrid. Explain what is wrong and what I have to do please. I have tried to Import the namespace Hamster and it didn't...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.