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 » GridCtrl: Find and Select Row after Keypress
GridCtrl: Find and Select Row after Keypress [message #19731] Wed, 07 January 2009 21:20 Go to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
I'm displaying some data within a GridCtrl. Now i want to select a row after pressing a key.

For example i have 4 rows with names:

---------col1----col2
row1 Michael Muller
row2 Albert Meier
row3 Hubert Heimer
row4 Silke Super

Now i want to press H and it would be great when row 3 would be selected. How can i realize this?

[Updated on: Wed, 07 January 2009 21:21]

Report message to a moderator

Re: GridCtrl: Find and Select Row after Keypress [message #19734 is a reply to message #19731] Thu, 08 January 2009 08:47 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

You can use Select* methods eg:
grid.Select(0, 15)
Re: GridCtrl: Find and Select Row after Keypress [message #19735 is a reply to message #19731] Thu, 08 January 2009 09:37 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Ok, but first i want to find the matching row. How can i find the first row which starts with H?
Re: GridCtrl: Find and Select Row after Keypress [message #19736 is a reply to message #19735] Thu, 08 January 2009 11:37 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

You can manually iterate over all grid rows:
FOREACH_ROW(grid)
{
   if(String(grid(NAME)).StartsWith("W"))
   {
      grid.Select(grid.GetCurrentRow());
   }
}

Probably there is no StartsWith method, but generally you can do it in this way.
Re: GridCtrl: Find and Select Row after Keypress [message #19737 is a reply to message #19736] Thu, 08 January 2009 13:16 Go to previous message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
This is what i have now:

FOREACH_ROW(datagrid)
	{
		if(String(datagrid(1)).IsEqual("Hubert"))
		{
			datagrid.SetCursor(datagrid.GetCurrentRow());
			datagrid.SelectRow();
			datagrid.SetFocus();
		}
	}


Now the row with Hubert at col1 is selected, but there is another problem: I use this code to make my next query:

activeCustomer = IntStr(datagrid.Get(2));
				
		CreateDatagrid("Server");
		SelectData("*", "Server", KUNDE == activeCustomer, ALIAS);


ActiveCustomer should be "Heimer", but it's not.

Is datgrid.get(col) the right method to get the value of an selected row? Hope you can follow me...

[Updated on: Thu, 08 January 2009 18:44]

Report message to a moderator

Previous Topic: GridCtrl - WhenRemoveRow doesn't work
Next Topic: HomeBudget AlwaysDrop
Goto Forum:
  


Current Time: Mon Apr 29 00:35:47 CEST 2024

Total time taken to generate the page: 0.03603 seconds