ListView'da seçili olan Item'ın Caption değerini fonksiyonla almaya çalışıyorum Access Violation hatası veriyor.
Sebebi ne olabilir, nereleri kontrol etmeliyim?
Kod: Tümünü seç
function TfrmMain.GetCurrentUnitName: String;
begin
Result := lsvComputers.Selected.Caption;
end;//GetCurrentUnitName
Kod: Tümünü seç
function TfrmMain.GetCurrentUnitName: String;
begin
Result := lsvComputers.Items.Item[lsvComputers.ItemIndex].Caption;
end;//GetCurrentUnitName
Itemları şu şekilde ekliyorum bundan dolayı olabilir mi?
Kod: Tümünü seç
procedure TfrmMain.AddComputer(Name: String);
var
ItemNo: Integer;
begin
with lsvComputers.Items do
begin
Add;
ItemNo := Count-1;
Item[ItemNo].Caption:=Name;
end;//with
end;//AddComputer