please tell me how to display data in DataGrid control, the simplest way to do it. please this is very urgent to me
Printable View
please tell me how to display data in DataGrid control, the simplest way to do it. please this is very urgent to me
What is your source of data? A recordset is best so you would only need to specify the binding to the grid.
this is my code im using ADO
my table has these fieldsCode:Private Sub Form_Load()
Set Cn = New ADODB.Connection
Cn.Provider = "Microsoft.Jet.OLEDB.4.0"
Cn.ConnectionString = App.Path & "\db1.mdb"
Cn.Open
Set Rs = New ADODB.Recordset
Rs.Open "Table1", Cn, adOpenDynamic, adLockOptimistic, adCmdTable
End Sub
f_name
l_name
address
phone
i want to show them in the Data Grid, i never used this control before. please give me very simple solution
I guess its best to figure out of a grid is the correct control for you..
Are your users going to be editing records?
I have used about every grid control there is but this one because it relies on a formal data structure. However, I dug this up for you.
"The DataGrid control in the "DataGrid Application" binds to a single DataSet object. The DataSet object of the "DataGrid Application" is initially populated from a database using an OleDbDataAdapter object.
What is a DataGrid?
The Windows Forms DataGrid control provides a user interface to ADO.NET datasets, displays ADO.NET tabular data in a scrollable grid, and allows for updates to the data source. In cases where the DataGrid is bound to a data source with a single table containing no relationships, the data appears in simple rows and columns, as in a spreadsheet. The DataGrid control is one of the most useful and flexible controls in Windows Forms. As soon as the DataGrid control is set to a valid data source, the control is automatically populated, by creating columns and rows based on the structure of the data. The DataGrid control can be used to display either a single table or the hierarchical relationships between a set of tables."
------------
That's as far as I can take you. Hope this helps get you started.
please tell me both for editing and the Grid you said aboveQuote:
Originally Posted by RobDog888
I think that is pertenant to VB.NET and not VB6 ;)Quote:
Originally Posted by Code Doc
The datagrid doesnt allow editing (or at least without much code and questionable logic :D) so if you need the users to be able to edit directly in the grid then you need to at best use a ListView and some semi-complicated code to "float" a textbox over the cell to "simulate" direct entry.Quote:
Originally Posted by chunk
Or use a 3rd party control.
Or use a set of textboxes at the top or bottom of the grid for editing the selected record. Then click an update button and have it update th record and relad the grid for ex.
You can edit, add and delete the data in a DataGrid. Set the AllowUpdate, AllowAdd and AllowDelete property to True. Are you asking how to load data into a DataGrid?
Ah so you can. Havent used it much at all. usually use Flexgrids or listviews. :thumb: But still using a bound control is problematic when you want to do filtering and searches etc.
thanks west4dbt, thanks Rob
i have uploaded a simple example on my other thread please see that and just change the fields name in the data grid
http://www.vbforums.com/showpost.php...63&postcount=4