Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Problems with ArrayCtrl, GridCtrl in my app
Problems with ArrayCtrl, GridCtrl in my app [message #14143] Thu, 14 February 2008 23:40 Go to next message
bytefield is currently offline  bytefield
Messages: 210
Registered: December 2007
Experienced Member
Hi. I make an app. which need to store some data in ArrayCtrl(or GridCtrl). After that my user can remove data from widget, clicking on a button from toolbar. The problem is with Remove. I've tried in so many different ways, but always i get an failed assertion(Vcont.h line 17).
Until now i didn't find how to remove a row from one of these controls(ArrayCtrl & GridCtrl)(removing correctly without problems Sad ). Maybe I'm ninny or something. I've tried to check if there is selected row in ctrl(with IsSelected, IsSelection and GetClickRow), but always I get into trouble.
If someone could post some example(with booth Grid and Array) about doing that, I will be tankful. The examples which comes with Upp don't cover this part of these Ctrls(only SQL stories which seems simple to remove data from grid or array with one query). (Hope you're understanding me. Thanks.
PS: Please reply quickly. I need solving it fast.


cdabbd745f1234c2751ee1f932d1dd75
Re: Problems with ArrayCtrl, GridCtrl in my app [message #14144 is a reply to message #14143] Thu, 14 February 2008 23:55 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Well, removing in both widgets should work just fine. Please prepare a test case. There must be something you're doing wrong Wink
Re: Problems with ArrayCtrl, GridCtrl in my app [message #14145 is a reply to message #14144] Fri, 15 February 2008 00:35 Go to previous messageGo to next message
bytefield is currently offline  bytefield
Messages: 210
Registered: December 2007
Experienced Member
Here is a test case.
  • Attachment: GridTC.zip
    (Size: 1.78KB, Downloaded 305 times)


cdabbd745f1234c2751ee1f932d1dd75
Re: Problems with ArrayCtrl, GridCtrl in my app [message #14150 is a reply to message #14145] Fri, 15 February 2008 16:02 Go to previous messageGo to next message
Alex is currently offline  Alex
Messages: 18
Registered: October 2007
Location: Germany
Promising Member
Hi,

I hope I have understood what you want to do.

	// case 1:
	int i = grid.GetCurrentRow();
	if(i >= 0)
		grid.Remove(i);


0 == false

You are right, there is a problem with IsSelected.
You need to test with IsSelected, otherwise rows also deleted that are not selected. And when the Grid is empty the "vcont.h line 17" error appears.

This seems to work:
	// case 1:
	int i;
	bool sel;
	int rowcount;
	
	rowcount = grid.GetCount();
	if (rowcount >0)
	{
		sel = grid.IsSelected();
		i = grid.GetCurrentRow();
		if( (i >= 0) && sel)
			grid.Remove(i);
	};


Regards Alex

[Updated on: Fri, 15 February 2008 16:28]

Report message to a moderator

Re: Problems with ArrayCtrl, GridCtrl in my app [message #14156 is a reply to message #14150] Fri, 15 February 2008 17:14 Go to previous messageGo to next message
bytefield is currently offline  bytefield
Messages: 210
Registered: December 2007
Experienced Member
Many thanks Smile It work. It seems to be my problem understanding how GridCtrl work (10996 lines of code Embarassed ).

It is better if someone with experience will fill this and append few lines to GridCtrl tutorial

From now on i will comment my source code Laughing . It is better to have it commented and know how it work than trying to think what it do (when you have clean Rolling Eyes source code).

Thanks for your help.


cdabbd745f1234c2751ee1f932d1dd75
Re: Problems with ArrayCtrl, GridCtrl in my app [message #14168 is a reply to message #14156] Sat, 16 February 2008 20:50 Go to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Yes, I know gridctrl is a big piece of code now without proper documentation. That will change soon (I hope Smile ).
Anyway, the easiest way to add deleting capability is to write
grid.Removing(). Since then you just open popup menu on given row and choose delete. What's more write grid.SetToolbar() to get internal toolbar with remove button visible. Internal removing operation works properly in multiselection mode and also it takes care of cursor postioning after deleting.
Remove, Insert, Append method are "raw methods" what means you have to be careful of passed parameters values.
You can also assign all this to your remove button. Just call grid.DoRemove() in it's callback.

[Updated on: Sat, 16 February 2008 20:51]

Report message to a moderator

Previous Topic: ArrayCtrl - How to Cancel EditMode? And other Problem
Next Topic: Problem w/ HeaderCtrl.SetPaper() in my app.
Goto Forum:
  


Current Time: Sat Apr 20 08:10:33 CEST 2024

Total time taken to generate the page: 0.03869 seconds