[Gambas-user] Possible bug in TableView
Charlie Reinl
na2492 at ...9...
Wed Feb 9 21:27:56 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
Salut,
yes you delete the record, but you don't realy refresh the tableview.
For doing that you have do pass by the tvType_Data event.
send you an no bound example, which you can use also for db-bounded
tableviews.
Amicalment
Charlie
* Gesendet mit / Sent by: FEN-Webmail * http://www.fen-net.de *
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XTableView-0.0.12.tar.gz
Type: application/x-tgz
Size: 30178 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20050209/16bd941c/attachment.bin>
More information about the User
mailing list