本文介绍了需要帮助(再次)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,在此C#作业中需要一些帮助:

Hey guys Need some help with this C# assignment:

创建一个名为LatestVisitedSites的项目,包含一个窗体,该窗体包含三个链接标签的列表,这些链接标签链接到任何三个网站 你选.当用户单击LinkLabel时,链接到该站点.当用户的鼠标悬停在LinkLabel上时,显示一条简短消息,说明站点的用途.用户单击链接后,将最近选择的链接移到列表顶部,然后 向下移动其他两个链接,并确保每个链接都保留正确的说明.

Create a project named RecentlyVisitedSites that contains a Form with a list of three LinkLabels that link to any three Web sites you choose. When a user clicks a LinkLabel, link to that site. When a user's mouse hovers over a LinkLabel, display a brief message that explains the site's purpose. After a user clicks a link, move the most recently selected link to the top of the list, and move the other two links down, making sure to retain the correct explanation with each link.

这是GUI表单的代码:

Here's the code of the GUI Form:

到目前为止,我已经完成了所有工作.但是当我单击它时,在将最近单击的链接移至顶部并将其他两个链接移至下方时,我需要帮助.最好是任何帮助.

So far I got everything done. But I need help in moving the recently clicked link up top and the other two down when I click on it. Any help would be best.

推荐答案

 public partial class Form1 : Form
    {
        LinkLabel googleLabel = new LinkLabel { Text = "Google" };
        LinkLabel facebookLabel = new LinkLabel { Text = "Facebook" };
        LinkLabel twitterLabel = new LinkLabel { Text = "Twitter" };

        FlowLayoutPanel panel = new FlowLayoutPanel();

        public Form1()
        {
            InitializeComponent();
            googleLabel.LinkClicked += googleLabel_LinkClicked;
            facebookLabel.LinkClicked += facebookLabel_LinkClicked;
            twitterLabel.LinkClicked += twitterLabel_LinkClicked;

            Controls.Add(panel);
            panel.Controls.Add(googleLabel);
            panel.Controls.Add(facebookLabel);
            panel.Controls.Add(twitterLabel);
        }

        private void googleLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("IExplore", "http://www.google.com");
            panel.Controls.SetChildIndex(googleLabel, 0);
        }

        private void facebookLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("IExplore", "http://www.facebook.com");
            panel.Controls.SetChildIndex(facebookLabel, 0);
        }

        private void twitterLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("IExplore", "http://www.twitter.com");
            panel.Controls.SetChildIndex(twitterLabel, 0);
        }
    }


希望有帮助.


Hope that helps.

请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.


这篇关于需要帮助(再次)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 23:36