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 » Community » Newbie corner » Grid Ctrl..How to find minimum and maximum element
Grid Ctrl..How to find minimum and maximum element [message #33234] Tue, 19 July 2011 07:56 Go to next message
Monty.mvh is currently offline  Monty.mvh
Messages: 31
Registered: July 2011
Location: Bangalore
Member
Hi frnz,

what is the format to access elements in Grid Ctrl .. say if i want to find min and max elements in a row of array of 5 numbers..

Regards
Monty
Re: Grid Ctrl..How to find minimum and maximum element [message #33243 is a reply to message #33234] Tue, 19 July 2011 22:48 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

You have to manually iterate over cells in a given row, for example:
GridCtrl grid;

int minValue = INT_MAX;
int maxValue = INT_MIN;
int row = 5;
for(int i = 0; i < grid.GetColumnsCount(); i++)
{
    int v = grid(row, i);

    if(minValue > v)
       v = minValue;
    else if(maxValue < v)
       v = maxValue;
}
Re: Grid Ctrl..How to find minimum and maximum element [message #33250 is a reply to message #33243] Wed, 20 July 2011 11:36 Go to previous messageGo to next message
Monty.mvh is currently offline  Monty.mvh
Messages: 31
Registered: July 2011
Location: Bangalore
Member
Thanks for the code..
I am getting an error saying

"error: ‘GridCtrl’ does not name a type"

after adding GridCtrl on the Layout..

I am not getting how to execute this code by adding GridCtrl onthe Layout..
Re: Grid Ctrl..How to find minimum and maximum element [message #33251 is a reply to message #33250] Wed, 20 July 2011 13:03 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Please open ide help and go to gridctrl section. There is a small tutorial how to use grid step by step.
Re: Grid Ctrl..How to find minimum and maximum element [message #33252 is a reply to message #33251] Wed, 20 July 2011 14:50 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Monty

In addition to unodgs advice, please check if GridCtrl.h is included before you include the layout in your C++ file.

For example:
#include <CtrlLib/CtrlLib.h>
#include <GridCtrl/GridCtrl.h>

using namespace Upp;

#define LAYOUTFILE <MyProject/MyProject.lay>
#include <CtrlCore/lay.h>


Best regards
Iñaki
Re: Grid Ctrl..How to find minimum and maximum element [message #33262 is a reply to message #33252] Thu, 21 July 2011 06:53 Go to previous messageGo to next message
Monty.mvh is currently offline  Monty.mvh
Messages: 31
Registered: July 2011
Location: Bangalore
Member
Thanks for the suggestion Koldo and Unodgs..
Header file was missing..Thanks again
I went thru the Help Section.
When i use the function "Add(grid.SizePos());",the GridCtrl gets added to the layout and it works fine..

In the manual they have not discussed about manual addition of GridCtrl to the layout but only using "Add(grid.SizePos());"

But when i manually add the GridCtrl to the layout and use it as similar to ArrayCtrl i get the error saying:

GridTrial.lay:3: error:‘class GridTrial’ has no member named‘grid’
GridTrial.lay:3: error:‘class GridTrial’ has no member named‘grid’
GridTrial.lay:3: error:‘class GridTrial’ has no member named‘grid’

But this doesnt happen while manually using ArrayCtrl on the layout.

Please do correct me if i am wrong..

Best Regards
Monty

[Updated on: Thu, 21 July 2011 07:39]

Report message to a moderator

Re: Grid Ctrl..How to find minimum and maximum element [message #33263 is a reply to message #33262] Thu, 21 July 2011 08:52 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Monty

In this cases is good to include a full project as simple as possible including the error.

Anyway I imagine you are adding a GridCtrl named "grid" in a class named "GridTrial" generated using the Layout Designer.

In fact when you add the grid in your layout, in the .lay files it appears something similar to the "Add(grid.SizePos());" you said, as the .lay is converted to C++ code.

To be sure, when you are in the Layout Designer, key Ctrl-T to see your layout in text:

LAYOUT(MyLayout, 428, 268)
	ITEM(GridCtrl, dv___0, HSizePosZ(116, 162).VSizePosZ(84, 84))
END_LAYOUT


and Ctrl-T again to see it graphically again:

index.php?t=getfile&id=3389&private=0

If you use a class like this:

class GridTrial : public WithMyLayout<StaticRect> {
...
};


"grid" is already a member of GridTrial as it has been included in "WithMyLayout", so you would have to use it in your program with no problem.


  • Attachment: dib.PNG
    (Size: 10.03KB, Downloaded 405 times)


Best regards
Iñaki
Re: Grid Ctrl..How to find minimum and maximum element [message #33275 is a reply to message #33263] Fri, 22 July 2011 06:24 Go to previous message
Monty.mvh is currently offline  Monty.mvh
Messages: 31
Registered: July 2011
Location: Bangalore
Member
Thanks Koldo;
I understood my mistake...Thank you very much
Previous Topic: Pick semantic errors
Next Topic: libnodave dll/lib include
Goto Forum:
  


Current Time: Thu Apr 18 09:33:36 CEST 2024

Total time taken to generate the page: 0.02345 seconds