Jump to content


Photo

NextGrid Row Click


  • Please log in to reply
14 replies to this topic

#1 Raven

Raven
  • Members
  • 9 posts

Posted 08 October 2006 - 10:53 AM

Hello! I am new here so I don't know if i posted this right.

So, I downloaded NextGrid and I have a little problem: I don't know how to detect when a user double clicks on a row. I want that text in that rows to be placed in a variable or something so i can edit it.

If you can help me, please add a reply.
Thank You

#2 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 08 October 2006 - 11:42 AM

Hi Raven

Try the following in the grid's doubleclick event:

CODE
procedure TForm1.NextGrid1DblClick(Sender: TObject);
var
  s: string;
begin
  //to get the text
  s := NextGrid1.Cells[0,NextGrid1.SelectedRow].AsString;
  //to set the text
  NextGrid1.Cells[0,NextGrid1.SelectedRow].AsString := s;
end;

(Replace "0" with column index for which you want the value)

#3 Raven

Raven
  • Members
  • 9 posts

Posted 08 October 2006 - 12:31 PM

Thanks a lot, deonvn...Your code helped me a lot!!
If i have any questios i'll post them here

#4 Raven

Raven
  • Members
  • 9 posts

Posted 10 October 2006 - 07:09 PM

So i did this:
CODE
procedure TForm1.NextGrid1DblClick(Sender: TObject);
var
  s: string;
  i:integer;
begin
  i:=NextGrid1.SelectedRow;
  s := NextGrid1.Cells[0,i]; ShowMessage(s);
end;

but when i double click on the grid nothing happens. What did I do wrong?
I must say that I am a beginner in OOP

#5 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 10 October 2006 - 08:26 PM

s := NextGrid1.Cells[0,i].AsString

Actually you don't even need the variables. You could just say:

ShowMessage(NextGrid1.Cells[0,NextGrid1.SelectedRow].AsString);

#6 Raven

Raven
  • Members
  • 9 posts

Posted 10 October 2006 - 08:47 PM

when i try your code I get this error:
QUOTE
[Error]Myfilename.pas[75]: Record, object or class type required

What is to be done? unsure.gif

#7 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 10 October 2006 - 09:58 PM

Sorry

Try using Cell instead of Cells

#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,196 posts
  • Gender:Male

Posted 11 October 2006 - 02:58 AM

Hello,

Yes, use Cell[x,y]. Thank you deonvn for helping smile.gif

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 Raven

Raven
  • Members
  • 9 posts

Posted 11 October 2006 - 07:31 PM

CODE
procedure TForm1.NextGrid1DblClick(Sender: TObject);
var
  s: string;
  i:integer;
begin
  //to get the text
  s := NextGrid1.Cell[0,NextGrid1.SelectedRow].AsString;
  ShowMessage(s);

end;
//End Next Grid1.DoubleClick

and it still doesn't work dry.gif

#10 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 11 October 2006 - 08:22 PM

Hi Raven

Did you add any rows to your grid (using AddRow)?

If so, does the first column of the row you are double-clicking on have any text in it?

#11 Raven

Raven
  • Members
  • 9 posts

Posted 11 October 2006 - 08:45 PM

1.I didn't use addRow. I used
CODE
NextGrid1.Addcells([a,b,c,d])

2.Yes. It looks like in this image
Attached File  berccomp.PNG   3.25KB   47 downloads

#12 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 11 October 2006 - 08:49 PM

It should work fine....

I have attached a sample with AddCells and DoubleClick.

Attached Files



#13 Raven

Raven
  • Members
  • 9 posts

Posted 12 October 2006 - 03:53 PM

When i try to compile it says:
CODE
[Fatal Error] Unit1.pas(7): File not found: 'NxCollection.dcu'

I'm using Delphi 7.
And when i try to compile without nxcollection.dcu it says "Could not create output file d:\projects\project1.exe"
but this project is stored in d:\downloads\doubleclick\

#14 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,196 posts
  • Gender:Male

Posted 12 October 2006 - 03:58 PM

Hello,

If you are using version without sources, simply remove NxCollection from unit from uses section.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#15 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 12 October 2006 - 05:47 PM

To fix the output path in the demo:

From the main menu, select Project --> Options.

On the Directories and Conditionals tab, change the output path to a path that exists (or make it blank).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users