MSFlexGrid RemoveItem

G

gti_jobert

Hi all,

I am populating an MSFlexGrid with rows of data manually on click of a
button....so it looks like the following:


Code:
--------------------

PD38 01822-00406 100394788 400 2 50 300 280 76000 600
11 50
PD38 01822-00406 100394791 50 11 20 30 280 4000 100
PD33 01810-10375 100394728 240 11 40 200 280 48000 300
PD33 01722-03509 100393890 210 1 20 160 260 29000 300
2 20
11 10
PD39 01821-00505 100398321 450 2 50 350 300 72000 500
11 50
PD07 01810-04998 100396409 450 11 80 370 240 72000 100
PD30 01722-03012 100390709 210 2 15 195 260 26000 200
PD30 01722-03010 100391991 240 2 10 210 260 32000 500
11 10
12 10

--------------------


As you can see from the above each *PD* can have a group of data. I
want to be able to click on .Col 0 in the MSFlexGrid and delete all
data that is grouped to the *PD* - I've been trying to use RemoveItem
(removes one line) but cant for the life of me think how to loop
through the data set and delete all data that belongs to a particular
*PD*.

Please help.....thanks all.
 
G

gti_jobert

Posting some code to see if it helps or if I'm on the right track;


Code
-------------------

count = 0
For i = frmMain.ProductionGrid.RowSel To frmMain.ProductionGrid.Rows - 1
frmMain.ProductionGrid.row = i
j = i
Do While Not j > frmMain.ProductionGrid.Rows - 1

If frmMain.ProductionGrid.TextMatrix(j, 0) = lblMachine1.Caption Or frmMain.ProductionGrid.TextMatrix(j, 0) = "" Then
If Not count >= 3 Then
frmMain.ProductionGrid.row = j
''SOME CODE HERE TO DELETE????
count = count + 1
End If
End If
j = j + 1
Loop
Exit For
Next

-------------------


Note: I cant just delete a row within this loop as all row indexes wil
change, so this is where I get a bit stuck.

TI
 
G

gti_jobert

OK its not pretty, but here is my fix:


Code
-------------------

rowSelect = frmMain.ProductionGrid.RowSel
count = 0: machineCount = 0
For i = frmMain.ProductionGrid.RowSel To frmMain.ProductionGrid.Rows - 1
frmMain.ProductionGrid.row = i
j = i
Do While Not j > frmMain.ProductionGrid.Rows - 1 And Not machineCount > 1

If frmMain.ProductionGrid.TextMatrix(j, 0) = lblMachine1.Caption Then
machineCount = 1
ElseIf frmMain.ProductionGrid.TextMatrix(j, 0) = "" Then
If Not count >= 2 Then
frmMain.ProductionGrid.row = j
count = count + 1
End If
End If
j = j + 1
Loop
Exit For
Next

For i = frmMain.ProductionGrid.RowSel To rowSelect Step -1
frmMain.ProductionGrid.row = i
frmMain.ProductionGrid.RemoveItem (frmMain.ProductionGrid.RowSel)
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top