这个问题怎么解决?

wwwsoft 2003-08-30 02:07:40
怎样用循环方法把菜单其中一列下拉菜单隐藏。
例如:

------------------
NWE
1
2
3
4
5
------------------

12345只要其中一项与edit1.text相同就隐藏。
...全文
25 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwsoft 2003-08-30
  • 打赏
  • 举报
回复
对对对,接分。

和VB有点意思。
FrameSniper 2003-08-30
  • 打赏
  • 举报
回复
呵呵,我还说nyf1220这家伙怎么研究起这个来了,闹了半天是看了这个帖子。呵呵....

procedure TForm1.Button1Click(Sender: TObject);
var
I:Integer;
ItemCaption:String;
begin
for I:=0 to MainMenu1.Items[0].Count-1 do
begin
ItemCaption:=MainMenu1.Items[0].Items [I].Caption ;
Delete(ItemCaption,Pos('&',ItemCaption),1);
if ItemCaption=Trim(Edit1.Text) then
MainMenu1.Items[0].Items[I].Visible:=False;
end;
end;

揭贴吧,楼主!

Eastunfail 2003-08-30
  • 打赏
  • 举报
回复
呵呵。你看看你的代码。

只能够处理第一层和第二层菜单。
把我上个帖子的递归一改,N层的照样修改
nyf1220 2003-08-30
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
begin
for j:=0 to MainMenu1.items.count-1 do
begin
if MenuItem1.Items[J].Caption := '你想隐藏菜单顶层的名字' then
begin
for i:=0 to MainMenu1.Items[0].Count-1 do
begin
if MainMenu1.Items[0].Items[i].Caption=edit1.Text then
MainMenu1.Items[0].Items[i].Visible:=false;
end;
end;
end;
不会还出错吧?
wwwsoft 2003-08-30
  • 打赏
  • 举报
回复
确实不错,但是出错!

全部代码给我看行吗?
请帮助。
Eastunfail 2003-08-30
  • 打赏
  • 举报
回复
没有我的好。

我用CompareText,可以忽略大小写。使应用程序更加灵活健壮,更加能够适应用户挑剔的选择。
但是比两个UpperCase后的字符串比较又要更加有效率。
Eastunfail 2003-08-30
  • 打赏
  • 举报
回复
没有我的好。

我用CompareText,可以忽略大小写。使应用程序更加灵活健壮,更加能够适应用户挑剔的选择。
但是比两个UpperCase后的字符串比较又要更加有效率。
nyf1220 2003-08-30
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to MainMenu1.Items[0].Count-1 do
begin
if MainMenu1.Items[0].Items[i].Caption=edit1.Text then
MainMenu1.Items[0].Items[i].Visible:=false;
end;
end;
这个可以吗?
Eastunfail 2003-08-30
  • 打赏
  • 举报
回复
些错了:
HiddenByName(Edit1.Text,NWE);
Eastunfail 2003-08-30
  • 打赏
  • 举报
回复
procedure HiddenByName(Name:string;Parent:TMenuItem);
var i:integer;
begin
for i:=0 to Parent.Count-1 do
if CompareText(Parent.Items[i].Caption,Name)=0 then
begin
Parent.Items[i].Visible:=false;
exit;//如果你要把所有和AName相同的都隐藏掉。去掉这个exit就可以了
end;
end;

HiddenByName(Edit1.Caption,NWE);

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧