Lazarus - SelectFirst 给出错误
Posted
技术标签:
【中文标题】Lazarus - SelectFirst 给出错误【英文标题】:Lazarus - SelectFirst Gives Error 【发布时间】:2013-06-05 11:58:25 【问题描述】:我正在尝试制作一个组合框,在更改后选择第一个项目。我的操作系统是 Ubuntu 12.04。我的代码:
unit Unit1;
$mode objfpc$H+
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, Menus;
type
TForm1
TForm1 = class(TForm)
ComboBox1: TComboBox;
Edit1: TEdit;
Label1: TLabel;
Memo1: TMemo;
procedure ComboBox1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
private declarations
public
public declarations
end;
var
Form1: TForm1;
implementation
$R *.lfm
TForm1
procedure TForm1.ComboBox1Change(Sender: TObject);
var Text2:String;
begin
if (Combobox1.ItemIndex = 1) Then
begin
Text2 := Memo1.SelText;
Edit1.Text := Memo1.SelText;
Memo1.SelText := '[artist]' + Text2 + '[/artist]';
end;
if (Combobox1.ItemIndex = 2) Then
begin
if (Edit1.Text = '') Then
ShowMessage('Artist name is not defined') Else
begin
Text2 := Memo1.SelText;
Memo1.SelText := '[album artist=' + Edit1.Text + ']' + Text2 + '[/album]';
end;
end;
if (ComboBox1.ItemIndex = 3) Then
begin
if (Edit1.Text = '') Then
ShowMessage('Artist name is not defined') Else
begin
Text2 := Memo1.SelText;
Memo1.SelText := '[track artist=' + Edit1.Text + ']' + Text2 + '[/track]'
end;
end;
if (ComboBox1.ItemIndex = 4) Then
begin
Text2 := Memo1.SelText;
Memo1.SelText := '[label]' + Text2 + '[/label]';
end;
if (ComboBox1.ItemIndex = 5) Then
begin
Text2 := Memo1.SelText;
Memo1.SelText := '[tag]' + Text2 + '[/tag]';
end;
Combobox1.SelectFirst;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Text := 'Select an item';
end;
end.
这给出了一个错误:unit1.pas(74,13) 错误:标识符 idents no member "SelectFirst"
我该如何解决这个问题?
【问题讨论】:
【参考方案1】:组合框没有这个程序 如果你想要第一个项目以这种方式选择它
ComboBox1.ItemIndex := 0
【讨论】:
以上是关于Lazarus - SelectFirst 给出错误的主要内容,如果未能解决你的问题,请参考以下文章