[Gambas-user] Possible bug in TableView

Eric Damron edamron at ...776...
Thu Feb 10 04:58:04 CET 2005


Charlie Reinl wrote:

>>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 *
>  
>
Thanks for your reply. 
The tvType_Data event gets triggered by the  RefreshTableView.

If I single step through the entire process the tableview gets updated 
properly but if I take the break point out it doesn't!




More information about the User mailing list