hi guys,
i am making invoice form in vb6, i have to make grid view so that user can add item details in row just by clicking on it and new Grid is open when user want to add new item.

productname description qnt rate amount




please help..

Recommended Answers

All 6 Replies

Are you use Vb.Net?
Also what you get so far?
Post your code here. Make some efforts.

i am using vb6 and access.

Dim cn As Connection
Dim rs As Recordset
Dim cm As Command
Private Sub Form_Load()

Set cn = New Connection
Set rs = New Recordset
Set cm = New Command
With cn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Tapati\Desktop\shyamnager\testrun2323.mdb;Persist Security Info=False"

End With
cm.ActiveConnection = cn
rs.Open "select * from test", cn, adOpenDynamic, adLockOptimistic

now i have datagrid.

grid will look like

productname description qnt rate amount


how can i do this?

Set this :

DataGrid1.AllowAddNew = True ' This line will add new row on datagrid
DataGrid1.AllowUpdate = True ' this line will let you to add data and edit data directly in datagrid

This line will add data directly to database when you write new data on datagrid

Also dont forget to set recordset as datagrid source. It will link database and datagrid.

Set DataGrid1.DataSource = rs

thank for reply Jx Man.
how can i calculate fields in datagrid colums and get the result in other colums.

Well.. Datagrid is not the control with that purpose.
You can't do many things like write directly to datagrid.
You can use flexgrid instead of datagrid.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.