Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSFlexGrid problem

Status
Not open for further replies.

belzeboom

Programmer
Sep 24, 2003
10
IT
Hi,
I have a problem:
I populate a MSFlex Grid by a DB:

Do While Not rst2.EOF
Griglia.AddItem item1 & vbTab & item2 & vbTab & item3 & vbTab & item4
rst2.MoveNext
Loop

also I Use a sub to sorting cols clicking on the header of column:

Private Sub Griglia_Click()

With Griglia
If .Row = 1 Then
If asc Then
.Sort = 2 'SortGenericDescending
asc = False
Else
.Sort = 1 'SortGenericAscending
asc = True
End If
End If
End With
End Sub

The problem is that when i load the grid, the first row is empty;
when I click into a column header for sorting, data begins from first row.
When I re-click data begins from second row,...

Anybody knows the problem ???

Thanx !
 
This is happening because the FlexGrid control defaults to 2 rows, so your additem is adding rows after the ones that are already there. The solution is to set the number of rows to 1 before you fill the grid:

Griglia.Rows = 1

Do While Not rst2.EOF
Griglia.AddItem item1 & vbTab & item2 & vbTab & item3 & vbTab & item4
rst2.MoveNext
Loop

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top