Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


highlight record in MSFlexGrid


highlight record in MSFlexGrid

Author
Message
Singaravelan
Singaravelan
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 67, Visits: 1
Dear Matt,

I tried use .SelLength to highlight the record, but unfortunetely i can make it.Can you help me to edit my code. Please.



Private Sub cmdNext_Click()

If Not Adodc1.Recordset.EOF Then

Adodc1.Recordset.MoveNext


If Adodc1.Recordset.EOF Then

Adodc1.Recordset.MovePrevious

End If
End If

End Sub




Private Sub Titles()

Dim startrow As Integer
Dim ColCount As Integer

emp.ActiveConnection = ConnectionString

With emp
.CursorType = adOpenDynamic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
End With

emp.Open "Select * from Employee"
emp.MoveFirst

MSFlexGrid1.Rows = emp.RecordCount + 1

MSFlexGrid1.Row = 0

MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "ID"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "NAME"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "WET WEIGHT"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "WET DRC"
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = "DRY WEIGHT"
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = "SCRAP"


With emp
.MoveFirst


For startrow = 1 To emp.RecordCount
For ColCount = 0 To 1
If ColCount = 0 Then

MSFlexGrid1.Row = startrow
MSFlexGrid1.Col = ColCount
MSFlexGrid1.Text = emp.Fields("EmpId").Value

Else

MSFlexGrid1.Row = startrow
MSFlexGrid1.Col = ColCount
MSFlexGrid1.Text = emp.Fields("EmpName").Value

End If

Next ColCount
emp.MoveNext
Next startrow

emp.MoveFirst
emp.Close
End With
End Sub

Public Sub Fills()

Dim startrow As Integer
Dim startcol As Integer

rubber.ActiveConnection = ConnectionString

With rubber
.CursorType = adOpenDynamic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
End With

rubber.Open "Select * from Daily_Rubber_Crop"

rubber.MoveFirst


For startrow = 1 To rubber.RecordCount
For startcol = 2 To 5
If Not rubber.EOF Then
If startcol = 2 Then
MSFlexGrid1.Row = startrow
MSFlexGrid1.Col = startcol
MSFlexGrid1.Text = rubber.Fields("Wet_Weight").Value

ElseIf startcol = 3 Then

MSFlexGrid1.Row = startrow
MSFlexGrid1.Col = startcol
MSFlexGrid1.Text = rubber.Fields("Wet_Drc").Value

ElseIf startcol = 4 Then

MSFlexGrid1.Row = startrow
MSFlexGrid1.Col = startcol
MSFlexGrid1.Text = rubber.Fields("Dry_Weight").Value

ElseIf startcol = 5 Then

MSFlexGrid1.Row = startrow
MSFlexGrid1.Col = startcol
MSFlexGrid1.Text = rubber.Fields("Scrap").Value

End If
End If
Next startcol
rubber.MoveNext
Next startrow

rubber.MoveFirst
rubber.Close

End Sub
Matt_Carter_25
Matt_Carter_25
Forum God
Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)

Group: Forum Members
Posts: 68, Visits: 1

ok you can use

flexgrid.rowsel and flexgrid.colsel

or if you want to highlight row 1

flexgrid.rowsel = 1

flexgrid.colsel = 5 (or the number of colomns your want to highlight)

so if you have 10 colomns then colsel = 10 ect

You will have to play around with it to sel the row to the record you on

but you also have a property on the flexgrid called selectionmode set this to select by row

see if this works

Matt


Singaravelan
Singaravelan
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 67, Visits: 1
Dear matt,
This is the code that i use to select row in flexgrid. When I click the next button, this code will operate. When i click the next button, it will compare the value in the text box and in the flexgrid.if the value matched, then it will highlight the row. Can you find out any error in this code?




Private Sub cmdNext_Click()
If Not Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveNext
Call mySuv
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MovePrevious
End If
End If
End Sub


Private Sub cmdPrev_Click()

If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveNext
End If
End If

End Sub


Private Sub mySuv()
Dim i As Integer
i = 1
Do While i <= Adodc1.Recordset.EOF

If txtName.Text = MSFlexGrid1.TextMatrix(i, 0) Then
With MSFlexGrid1
.Row = 1
.ColSel = 1
.SetFocus
End With
End If
Loop
End Sub


regards
Singaravelan
Matt_Carter_25
Matt_Carter_25
Forum God
Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)Forum God (5.4K reputation)

Group: Forum Members
Posts: 68, Visits: 1

If you gonna loop through the grid you need to index the row you wish to highlight

If txtName.Text = MSFlexGrid1.TextMatrix(i, 0) Then
With MSFlexGrid1
.Row = recordset.absoluteposition - 1
.ColSel = 'indicate how many columns you wish to highlight here
End With
End If
Loop
End Sub

try this

Matt


jamunadevi
jamunadevi
Forum God
Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)

Group: Forum Members
Posts: 2, Visits: 2
is there any possible way to highlight a search word in mshflexgrid using vb6.0

jamunadevi
jamunadevi
Forum God
Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)Forum God (718 reputation)

Group: Forum Members
Posts: 2, Visits: 2
i want a code to highlight a search word in mshflexgrid.. i have code for search i just want to know how to highlight that search word in mshflexgrid using vb6.0.. pls help me guys
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search