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 » GridCtrl - get width column
Re: GridCtrl - get width column [message #57305 is a reply to message #57304] Fri, 02 July 2021 04:41 Go to previous message
BetoValle is currently offline  BetoValle
Messages: 204
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,

my case had 14 columns and after that I added the names and initially set a ratio. As the names of some columns were partially visible, so I wanted to build an function to just load the application and at runtime better define the adjust aspect ratio to display the full names of the columns. Among the initial question, I also started to take a look at the sources. In addition to your good suggestion (because without it had no idea that the column displays accumulated width / grid.GetWidth(index) ). But it would be interesting who produced the sources also gradually document the GridCtrl to also clarify the differences for example between fixed_cols, total_cols and GetColumnCount() and mainly how use them!

So I also found grid.Header().GetColumnWidths() which returns a string with sizes delimited with whitespace. This is now easier although you also have to remove spaces and index as below. I'll just leave it registered here because it might be useful for other developers.


	LOG( " width by accumulated in column / fixed_cols / total_cols---------- " << EOL );
	
	for ( int i = gPr.fixed_cols; i <= gPr.total_cols; i++ )
	{	
  	  if(i>1)    
  	   LOG( "column " << gPr.GetColumnName(i-2).ToString() << ": " << (gPr.GetWidth (i) - gPr.GetWidth (i- 1)) << EOL);
	} 
	
	LOG(  " width by GetColumnWidths / GetColumnCount ----------- " << EOL);
	
        String s =  gPr.Header().GetColumnWidths();
	
	Vector<String> words = Split(s, [](int c) { return c == ':' || c == '\t' || c == ' ' || c == ',' || c == '.' ? 1 : 0; });
	Vector<String> vnome;
	for(const auto& r : words)
            vnome.Add( r );

	for ( int i = 0; i < gPr.GetColumnCount(); i++ )
	  LOG( gPr.GetColumnName(i).ToString() << " width: " << vnome[i] << " \n");



Thanks


 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Ultimate++ vs Wxwidgets for desktop linux/windows/mac app
Next Topic: Linux Executable
Goto Forum:
  


Current Time: Fri Aug 22 06:48:44 CEST 2025

Total time taken to generate the page: 0.09367 seconds