我想在winform中实现滚动消息,并且在单击消息内容时连接到相应的页面,现在实现了消息滚动,但不知道怎么在StatusBar控件中添加linklabel

解决方案 »

  1.   

    怎么没人帮忙啊,我只想在winform中制作个可以连接的滚动消息啊
      

  2.   

    设置鼠标经过StatusBar时候的光标
    捕获点击事件
      

  3.   

    private void statusBar1_PanelClick(object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e)
    {
    System.Diagnostics.Process.Start("explorer.exe",e.StatusBarPanel.ToolTipText);
    } private void Form1_Load(object sender, System.EventArgs e)
    {
    statusBar1.Cursor = Cursors.Hand; statusBar1.Panels[0].Text = "CSDN";
    statusBar1.Panels[0].ToolTipText = "http://www.csdn.net";
    statusBar1.Panels[1].Text = "SINA";
    statusBar1.Panels[1].ToolTipText = "http://www.sina.com.cn"; statusBar1.Panels[0].Width = 200;
    statusBar1.Panels[1].Width = 200;
    }
      

  4.   

    谢谢oolongTea(乌龙茶) ,但panel不能滚动啊 现在我只能实现在一个panel里实现字体滚动,有没有办法让状态栏的都实现滚动
      

  5.   

    yistudio(阳光灿烂的日子) ,能具体给点代码提示吗,谢谢
      

  6.   

    我现有的代码是这样的,但只能实现panel内滚动
    statusBar1.Cursor = Cursors.Hand;
    StatusBarPanel panel1 = new StatusBarPanel();
    StatusBarPanel panel2 = new StatusBarPanel();
    panel1.Text = this.news;
    panel1.ToolTipText = "http://www.csdn.net";
    panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken;
    panel2.ToolTipText = "http://www.sina.com.cn";
    panel2.BorderStyle = StatusBarPanelBorderStyle.Sunken;
    panel2.Text = "";
    panel2.Width = 20;
    statusBar1.ShowPanels = true;
    statusBar1.Panels.Add(panel2);
    statusBar1.Panels.Add(panel1);
    while(true)
    {

    panel1.Text = this.news;
    this.data = panel1.Text;


    while(!data.Equals(""))
    {
    Thread.Sleep(500);
             panel1.Text = panel1.Text.Substring(1) + data[0];
    data = data.Substring(1);
    }
    }
      

  7.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace test
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.LinkLabel linkLabel1;
    private System.Windows.Forms.Timer timer1;
    private System.Windows.Forms.StatusBar statusBar1;
    private System.Windows.Forms.StatusBarPanel statusBarPanel1;
    private System.Windows.Forms.StatusBarPanel statusBarPanel2;
    private System.Windows.Forms.StatusBarPanel statusBarPanel3;
    private System.Windows.Forms.Panel panel1;
    private System.ComponentModel.IContainer components; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.components = new System.ComponentModel.Container();
    this.linkLabel1 = new System.Windows.Forms.LinkLabel();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    this.statusBar1 = new System.Windows.Forms.StatusBar();
    this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
    this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
    this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
    this.panel1 = new System.Windows.Forms.Panel();
    ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
    ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
    ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
    this.panel1.SuspendLayout();
    this.SuspendLayout();
    // 
    // linkLabel1
    // 
    this.linkLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    this.linkLabel1.Location = new System.Drawing.Point(8, -2);
    this.linkLabel1.Name = "linkLabel1";
    this.linkLabel1.Size = new System.Drawing.Size(376, 14);
    this.linkLabel1.TabIndex = 0;
    this.linkLabel1.TabStop = true;
    this.linkLabel1.Text = "意甲-克雷斯波助国米4-3胜切沃跃居榜首 罗马大胜  西甲巴萨主场6年不胜瓦伦 邵佳一首发科特布斯战平";
    // 
    // timer1
    // 
    this.timer1.Enabled = true;
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    // 
    // statusBar1
    // 
    this.statusBar1.Location = new System.Drawing.Point(0, 447);
    this.statusBar1.Name = "statusBar1";
    this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
      this.statusBarPanel1,
      this.statusBarPanel2,
      this.statusBarPanel3});
    this.statusBar1.ShowPanels = true;
    this.statusBar1.Size = new System.Drawing.Size(664, 22);
    this.statusBar1.TabIndex = 2;
    this.statusBar1.Text = "statusBar1";
    // 
    // statusBarPanel1
    // 
    this.statusBarPanel1.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.Raised;
    this.statusBarPanel1.Text = "这里是中国";
    // 
    // statusBarPanel2
    // 
    this.statusBarPanel2.Text = "这里是我国";
    // 
    // statusBarPanel3
    // 
    this.statusBarPanel3.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
    this.statusBarPanel3.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.Raised;
    this.statusBarPanel3.Width = 448;
    // 
    // panel1
    // 
    this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
    | System.Windows.Forms.AnchorStyles.Right)));
    this.panel1.Controls.Add(this.linkLabel1);
    this.panel1.Location = new System.Drawing.Point(240, 454);
    this.panel1.Name = "panel1";
    this.panel1.Size = new System.Drawing.Size(400, 14);
    this.panel1.TabIndex = 3;
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(664, 469);
    this.Controls.Add(this.panel1);
    this.Controls.Add(this.statusBar1);
    this.Name = "Form1";
    this.Text = "Form1";
    ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
    ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
    ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
    this.panel1.ResumeLayout(false);
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }
    private void Form1_Load(object sender, System.EventArgs e)
    {
    this.timer1.Enabled = true;
    } int location = 0;
    int lableLenth = 100;
    private void timer1_Tick(object sender, System.EventArgs e)
    { if(location > this.panel1.Width)
    {
    location = 0 - lableLenth;
    } this.linkLabel1.Location = new System.Drawing.Point(location, 0);
    location += 5; }
    }
    }