como descubro qual a linha do listview foi selecionada?

Delphi

04/11/2007

Olá,

Como eu descubro qual a linha do listview foi selecionada? Tentei usar o itemindex, mas dá erro?


Rsa_tche

Rsa_tche

Curtidas 0

Respostas

Edilcimar

Edilcimar

04/11/2007

Coloque no onmousedown
ValueListEditor.MouseToCell(X,Y,ACol,ARow);
ValorDesejado1 := ValueListEditor.Cells[0,Arow];
ValorDesejadoN := ValueListEditor.Cells[N-1,Arow]);


GOSTEI 0
Massuda

Massuda

04/11/2007

Use a propriedade [b:8cee240f0b]TListView.Selected[/b:8cee240f0b]. Ela contem o [b:8cee240f0b]item [/b:8cee240f0b]selecionado ou nil se não houver item selecionado.


GOSTEI 0
Rsa_tche

Rsa_tche

04/11/2007

Olá,

dá erro na linha do ValueListEditor.MouseToCell(X,Y,ACol,ARow);


GOSTEI 0
Rsa_tche

Rsa_tche

04/11/2007

Olá, com o TlistView.Selected funcionou.

Fiz assim:
if ListView1.Selected <> nil then
begin
ListItem := ListView1.Selected;
Edt_descricao.Text:= ListItem.Caption;
Edt_preco.Text:= ListItem.Subitems[0];
Edt_imagem.Text:= ListItem.Subitems[1];
end;


GOSTEI 0
Edilcimar

Edilcimar

04/11/2007

eu uso exatamente isto aqui para pegar o icms em uma venda e funciona perfeitamente
procedure TForm94.ValueListEditor2MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
ACol, ARow : Integer;
begin
ValueListEditor2.MouseToCell(X,Y,ACol,ARow);
If (ARow >= 0) and (ARow < ValueListEditor2.RowCount) then
Begin
Cfop := ValueListEditor2.Cells[0,Arow];
Icms := StrToFloat(ValueListEditor2.Cells[1,Arow]);
End
Else
ValueListEditor2.ShowHint := False;
end;


GOSTEI 0
POSTAR