我该怎么做?才能知道是那个stringgrid的对应行,主要是知道是那个stringgrid?

解决方案 »

  1.   

    yourgird.row是行
    yourgrid.col是列。yourgrid.Name属性就可以知道是那个了。
      

  2.   

    通过控件的tag来判断是哪一个stringgrid
    当然你要设定好TAG值了。
    如:STRINGGRID1 TAG:1
        STRINGGRID2 TAG:2
        STRINGGRID3 TAG:3
        ..
    procedure TForm1.Button1Click(Sender: TObject);
    var
      I: Integer;
      Temp: Tcomponent;
    begin
      for I := ComponentCount - 1 downto 0 do
      begin
        Temp := Components[I];
        if (Temp is Tstringgrid) then
        begin
          showmessage(inttostr(temp.tag));
        end;
      end;end;
      

  3.   

    其实,只要获取弹出菜单的控件就可以啦。
    你可以试试PopupMenu1.PopupComponent下面是我刚刚试写的代码,其中PMNCaption是PopupMenu1的一个菜单项
    procedure TForm1.PopupMenu1Popup(Sender: TObject);
    begin
      if (PopupMenu1.PopupComponent=StringGrid1) then
      begin
        PMNCaption.Caption :='OhMyGod';
      end
      else
      begin
        PMNCaption.Caption :=(PopupMenu1.PopupComponent As TControl).Name;
      end;
    end;
      

  4.   

    procedure TForm1.StringGrid1Click(Sender: TObject);
    begin
      if (ActiveControl is TStringGrid) then
        showmessage(IntToStr(TStringGrid(ActiveControl).Tag));
    end;
      

  5.   

    StringGrid1.Tag:0
    StringGrid2.Tag:1
    StringGrid3.Tag:2
    if (ActiveControl is TStringGrid) then
      case TStringGrid(ActiveControl).Tag of
        0://to do 
        1://to do
        2://to do
      end