[Gambas-user] Possible bug in TableView
Eric Damron
edamron at ...776...
Wed Feb 9 03:04:29 CET 2005
I have a form with a table view. When I delete the top item then reload
the data and refresh the table view everything is fine unless I'm down
to two items. When I only have two items the correct item gets deleted
from the MySQL database but when it refreshes it still shows up in the
list and the item below it is gone!
Here is come code:
I click an item to select it:
PUBLIC SUB tvType_Click()
DIM rsRecord AS Result
DIM strDescription AS String
strDescription = tvType[tvType.Row, 1].Text
TRY rsRecord = frmMain.hConnection.Exec("select id from TYPE where
description = (&1)", strDescription)
tvType.Tag = Str(rsRecord["id"])
CATCH
Message("tvType_Click: " & Error.Text)
END
Then I click the delete button:
PUBLIC SUB cmdDelete_Click()
TRY frmMain.hConnection.Exec("delete FROM TYPE where id = " & tvType.Tag)
LoadData
CATCH
Message("cmdDelete_Click: Error " & Error.Text)
END
This Exec the sql that deletes the row and then loads the data:
PRIVATE SUB LoadData()
IF frmMain.bConnected THEN
TRY rsType = frmMain.hConnection.Exec("select * from TYPE order by
description")
RefreshTableView
CATCH
Message("Error loading Type data.")
END IF
END
The LoadData sub calls the RefreshTableView sub:
PRIVATE SUB RefreshTableView()
WITH rsType
IF .Count > 0 THEN
tvType.Rows.Count = .Count
ELSE
ClearType
END IF
END WITH
CATCH
Message("Error refreshing tableview")
END
This triggers the TableView's Data event:
PUBLIC SUB tvType_Data(Row AS Integer, Column AS Integer)
IF rsType.Count > 0 THEN
rsType.MoveTo(Row)
SELECT CASE Column
CASE 1 ' description
tvType.Data.Text = Str(rsType["description"])
END SELECT
END IF
END
I don't see any error. Is this a bug in the TableView control?
Thanks
More information about the User
mailing list