Skip to main content

Sort datagrid by clicking on head of column

Hi friends!
this code will help to sort data in datagridview

Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Adodc1.Recordset.Sort = DataGrid1.Columns(ColIndex).DataField
End Sub

please comment if this code help you!

Comments

  1. It is very helpful...thanks for that๐Ÿ˜Š๐Ÿ‘

    ReplyDelete

Post a Comment

Popular posts from this blog

Search in Datagrid in vb6.0

You can search item through this code on keypress in datagrid, Like if you press 1 in textbox then all record starts from 1***** will be displayed, without hitting any other button. Private Sub text_change() With recordset If .State adStateClosed Then .Close End If .Open "select * from table where empid like'" & Text1.Text & "%'", con, adOpenDynamic, adLockOptimistic Set DataGrid1.DataSource = recordset End With End Sub comment if this code helps u

generate auto ID number

This code will generate auto id number for the unique id. Public Sub id() Dim lastnumber As Long, newnumber As Long 'Check if there are records in the file With recordset If .BOF = True And .EOF = True Then lastnumber = (any number) Else .MoveLast lastnumber = !field in recordset End If 'Generate New Number newnumber = lastnumber + 1 Text1.Text = newnumber End With End Sub please comment if this post helps you.....

Load combobox with items from database

The given code will help to get database value in your combobox. public con as new adodb.connection public rs as new adodb.recordset rs.Open "Select (data field to load in combobox) from (tablename) ", con, adOpenForwardOnly, adLockReadOnly While rs.EOF = False Combo1.AddItem rs!(data field to load in combobox) rs.MoveNext Wend