Deleting Excess rows of MSFlexGrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MiziaQ
    New Member
    • Nov 2007
    • 63

    Deleting Excess rows of MSFlexGrid

    Hey, I'm using the following code to filter an msflexgrid to only display
    rows with the entry "East Cork" in the 8th column. The table has many more entries, so, when I run the application, many rows are left blank. How can I get rid of these rows ? Here's my code, thanks in advance

    Private Sub Form_Load()

    MSFlexGrid1.All owUserResizing = flexResizeColum ns
    MSFlexGrid1.Sel ectionMode = flexSelectionBy Row

    MSFlexGrid1.Tex tMatrix(0, 0) = "ID"
    MSFlexGrid1.Tex tMatrix(0, 1) = "Customer"
    MSFlexGrid1.Tex tMatrix(0, 2) = "Pickup Name"
    MSFlexGrid1.Tex tMatrix(0, 3) = "Pickup Address"
    MSFlexGrid1.Tex tMatrix(0, 4) = "Pickup Area"
    MSFlexGrid1.Tex tMatrix(0, 5) = "Telephone Number(s)"
    MSFlexGrid1.Tex tMatrix(0, 6) = "Delivery Name"
    MSFlexGrid1.Tex tMatrix(0, 7) = "Delivery Address"
    MSFlexGrid1.Tex tMatrix(0, 8) = "Destinatio n Area"
    MSFlexGrid1.Tex tMatrix(0, 9) = "Telephone Numbers(s)"
    MSFlexGrid1.Tex tMatrix(0, 10) = "Weight of Package (in kg)"
    MSFlexGrid1.Tex tMatrix(0, 11) = "Delivery Price"
    MSFlexGrid1.Tex tMatrix(0, 12) = "Pickup Date"
    MSFlexGrid1.Tex tMatrix(0, 13) = "Delivery Date"
    MSFlexGrid1.Tex tMatrix(0, 14) = "Priority"

    MSFlexGrid1.Col Width(0) = 2000
    MSFlexGrid1.Col Width(1) = 2500
    MSFlexGrid1.Col Width(2) = 2500
    MSFlexGrid1.Col Width(3) = 2750
    MSFlexGrid1.Col Width(4) = 2500
    MSFlexGrid1.Col Width(5) = 2500
    MSFlexGrid1.Col Width(6) = 2500
    MSFlexGrid1.Col Width(7) = 2750
    MSFlexGrid1.Col Width(8) = 2500
    MSFlexGrid1.Col Width(9) = 2500
    MSFlexGrid1.Col Width(10) = 2500
    MSFlexGrid1.Col Width(8) = 2500
    MSFlexGrid1.Col Width(9) = 2500
    MSFlexGrid1.Col Width(10) = 2500
    MSFlexGrid1.Col Width(11) = 2500
    MSFlexGrid1.Col Width(12) = 2500
    MSFlexGrid1.Col Width(13) = 2500
    MSFlexGrid1.Col Width(14) = 2500

    Open App.Path & "\deliveries.tx t" For Input As #12

    Dim oldRow As Long
    Dim lngRow As Long
    Dim lngCol As Long
    Dim i As Long

    Dim tRow As Long
    Dim tCol As Long


    Dim strID As String

    MSFlexGrid1.Row s = 2

    Do Until EOF(12)

    Input #12, strID, strCustomer, strPickupName, strPickupAddres s, strPickupArea, strPTelephoneNu mbers, strDeliveryName , _
    strDeliveryAddr ess, strDestinationA rea, strDTelephoneNu mbers, strWoP, strDeliveryPric e, _
    strPickupDate, strDeliveryDate , strPriority

    If frmLogin.cboLog in.Text = "Kevin" And strDestinationA rea = "East Cork" Then


    MSFlexGrid1.Tex tMatrix(1, 0) = strID
    MSFlexGrid1.Tex tMatrix(1, 1) = strCustomer
    MSFlexGrid1.Tex tMatrix(1, 2) = strPickupName
    MSFlexGrid1.Tex tMatrix(1, 3) = strPickupAddres s
    MSFlexGrid1.Tex tMatrix(1, 4) = strPickupArea
    MSFlexGrid1.Tex tMatrix(1, 5) = strPTelephoneNu mbers
    MSFlexGrid1.Tex tMatrix(1, 6) = strDeliveryName
    MSFlexGrid1.Tex tMatrix(1, 7) = strDeliveryAddr ess
    MSFlexGrid1.Tex tMatrix(1, 8) = strDestinationA rea
    MSFlexGrid1.Tex tMatrix(1, 9) = strDTelephoneNu mbers
    MSFlexGrid1.Tex tMatrix(1, 10) = strWoP
    MSFlexGrid1.Tex tMatrix(1, 11) = strDeliveryPric e
    MSFlexGrid1.Tex tMatrix(1, 12) = strPickupDate
    MSFlexGrid1.Tex tMatrix(1, 13) = strDeliveryDate
    MSFlexGrid1.Tex tMatrix(1, 14) = strPriority

    End If


    MSFlexGrid1.Row s = MSFlexGrid1.Row s + 1
    For lngRow = MSFlexGrid1.Row s - 2 To MSFlexGrid1.row Step -1
    For lngCol = 0 To MSFlexGrid1.Col s - 1
    MSFlexGrid1.Tex tMatrix(lngRow + 1, lngCol) = MSFlexGrid1.Tex tMatrix(lngRow, lngCol)
    If lngRow = MSFlexGrid1.row Then
    MSFlexGrid1.Tex tMatrix(lngRow, lngCol) = "" 'Make the current row empty
    End If
    Next
    Next

    i = 0

    Loop

    Close #12

    Do While i < MSFlexGrid1.Row s

    If MSFlexGrid1.Tex tMatrix(i, 0) = "" Then

    MSFlexGrid1.Rem oveItem i

    End If

    i = i + 1

    Loop

    MSFlexGrid1.Col = 13
    MSFlexGrid1.Sor t = flexSortStringA scending

    For tRow = 1 To MSFlexGrid1.Row s - 1

    MSFlexGrid1.row = tRow

    If MSFlexGrid1.Tex tMatrix(tRow, 14) = "Low" Then

    For tCol = 0 To MSFlexGrid1.Col s - 1

    MSFlexGrid1.Col = tCol
    MSFlexGrid1.Cel lBackColor = RGB(204, 255, 153)

    Next

    ElseIf MSFlexGrid1.Tex tMatrix(tRow, 14) = "Medium" Then

    For tCol = 0 To MSFlexGrid1.Col s - 1

    MSFlexGrid1.Col = tCol
    MSFlexGrid1.Cel lBackColor = RGB(202, 225, 255)

    Next

    ElseIf MSFlexGrid1.Tex tMatrix(tRow, 14) = "High" Then

    For tCol = 0 To MSFlexGrid1.Col s - 1

    MSFlexGrid1.Col = tCol
    MSFlexGrid1.Cel lBackColor = RGB(255, 228, 225)

    Next

    End If

    Next

    End Sub
Working...