| 
 | 
 | 
 
Home » Community » Newbie corner » Grid Ctrl..How to find  minimum and maximum element 
	| 
		
 |  
	
		
		
			| Re: Grid Ctrl..How to find  minimum and maximum element [message #33243 is a reply to message #33234] | 
			Tue, 19 July 2011 22:48    | 
		 
		
			| 
				
	 | 
 
	
		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 #33262 is a reply to message #33252] | 
			Thu, 21 July 2011 06:53    | 
		 
		
			
				
				
				
					
						  
						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    | 
		 
		
			
				
				
				  | 
					
						  
						koldo
						 Messages: 3453 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: 
 
  
 
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 559 times)
 
 
		
  Best regards 
Iñaki
		
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 11:03:31 CET 2025 
 Total time taken to generate the page: 0.06791 seconds 
 |   
 |  
  |