|
|
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  |
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 ). 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 #14150 is a reply to message #14145] |
Fri, 15 February 2008 16:02   |
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 #14168 is a reply to message #14156] |
Sat, 16 February 2008 20:50  |
|
Yes, I know gridctrl is a big piece of code now without proper documentation. That will change soon (I hope ).
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
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:41:15 CEST 2025
Total time taken to generate the page: 0.00927 seconds
|
|
|