473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Deleting Excess rows of MSFlexGrid

63
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.AllowUserResizing = flexResizeColumns
MSFlexGrid1.SelectionMode = flexSelectionByRow

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

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

Open App.Path & "\deliveries.txt" 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.Rows = 2

Do Until EOF(12)

Input #12, strID, strCustomer, strPickupName, strPickupAddress, strPickupArea, strPTelephoneNumbers, strDeliveryName, _
strDeliveryAddress, strDestinationArea, strDTelephoneNumbers, strWoP, strDeliveryPrice, _
strPickupDate, strDeliveryDate, strPriority

If frmLogin.cboLogin.Text = "Kevin" And strDestinationArea = "East Cork" Then


MSFlexGrid1.TextMatrix(1, 0) = strID
MSFlexGrid1.TextMatrix(1, 1) = strCustomer
MSFlexGrid1.TextMatrix(1, 2) = strPickupName
MSFlexGrid1.TextMatrix(1, 3) = strPickupAddress
MSFlexGrid1.TextMatrix(1, 4) = strPickupArea
MSFlexGrid1.TextMatrix(1, 5) = strPTelephoneNumbers
MSFlexGrid1.TextMatrix(1, 6) = strDeliveryName
MSFlexGrid1.TextMatrix(1, 7) = strDeliveryAddress
MSFlexGrid1.TextMatrix(1, 8) = strDestinationArea
MSFlexGrid1.TextMatrix(1, 9) = strDTelephoneNumbers
MSFlexGrid1.TextMatrix(1, 10) = strWoP
MSFlexGrid1.TextMatrix(1, 11) = strDeliveryPrice
MSFlexGrid1.TextMatrix(1, 12) = strPickupDate
MSFlexGrid1.TextMatrix(1, 13) = strDeliveryDate
MSFlexGrid1.TextMatrix(1, 14) = strPriority

End If


MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
For lngRow = MSFlexGrid1.Rows - 2 To MSFlexGrid1.row Step -1
For lngCol = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.TextMatrix(lngRow + 1, lngCol) = MSFlexGrid1.TextMatrix(lngRow, lngCol)
If lngRow = MSFlexGrid1.row Then
MSFlexGrid1.TextMatrix(lngRow, lngCol) = "" 'Make the current row empty
End If
Next
Next

i = 0

Loop

Close #12

Do While i < MSFlexGrid1.Rows

If MSFlexGrid1.TextMatrix(i, 0) = "" Then

MSFlexGrid1.RemoveItem i

End If

i = i + 1

Loop

MSFlexGrid1.Col = 13
MSFlexGrid1.Sort = flexSortStringAscending

For tRow = 1 To MSFlexGrid1.Rows - 1

MSFlexGrid1.row = tRow

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

For tCol = 0 To MSFlexGrid1.Cols - 1

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

Next

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

For tCol = 0 To MSFlexGrid1.Cols - 1

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

Next

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

For tCol = 0 To MSFlexGrid1.Cols - 1

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

Next

End If

Next

End Sub
Mar 18 '08 #1
0 1280

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am...
5
by: Patrick Vanden Driessche | last post by:
Hi All, I'm currently writing an in-house Form validation framework (WinForms) which is based on 'Component'-inheriting object. So basically, I have a small hierarchy. FormValidator +--...
0
by: Martin K | last post by:
Hello all..thanks for everyone's advice regarding my SHBrowseForFolder API problem, I was able to put together a public class that runs great! But I have another migration headache regarding the...
0
by: snowe | last post by:
HI I am now difficult to get the row index in MsFlexGrid when we right click on rows. And how to add the controls in Ms FlexGrid in VB.Net. ...
0
by: debjanidutta090483 | last post by:
How different forecolor is given in different rows of a MSFlexGrid in VB6 during runtime?
3
by: mahesh123 | last post by:
Hi, I want to select the records in multiselection randomly in the MSFlexGrid? In MSFlexGrid there is multiselection option by press the Shift key and select the records, but there we can...
1
by: MiziaQ | last post by:
Hey, how can I delete an entire row from an MSFlexGrid table, and how can I allow the user to only select one row (i.e. not allow multiselection of rows ?) Thanks in advance, MiziaQ
3
by: MiziaQ | last post by:
Hey, I would like to delete a row of data from my data file, though using an MSFlexGrid. I can currently delete any selected row, though it only deletes a row from the Grid, and not the entry itself....
4
by: MiziaQ | last post by:
Hey, I'm using the following code to write entries to a data file and then read them in an msflexgrid. I now would like to add code under a delete button to use the table(grid) to delete rows from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.