我想在程序里面实现  把任务栏隐藏,并且窗体充满整个屏幕  [DllImport("user32.dll")]  
  internal  static  extern  IntPtr  FindWindow(string  lpClassName,  string  lpWindowName);  
    
  [DllImport("user32.dll")]  
  internal  static  extern  int  ShowWindow(IntPtr  hWin,  int  nCmdShow);这两个函数  实现了隐藏,但是窗体不能充满屏幕 求教 谢谢

解决方案 »

  1.   

    窗体的StartPosition设置为CenterScreen
    不要最大化,直接调整窗体的大小
      

  2.   

    设置窗口的大小为屏幕即可://这个函数是用来获取屏幕的显示区域的,包括多显示器的
    private Rectangle GetAllScreenBounds() 

    Rectangle rect = new Rectangle(0, 0, 0, 0); 
    foreach (Screen screen in Screen.AllScreens) 

    Rectangle rectScreen = screen.Bounds; 
    if (rectScreen.Left < rect.Left) 

    rect.Width += (rect.Left - rectScreen.Left); 
    rect.X = rectScreen.X; 

    if (rectScreen.Right > rect.Right) 
    rect.Width += (rectScreen.Right - rect.Right); 
    if (rectScreen.Top < rect.Top) 

    rect.Height += (rect.Top - rectScreen.Top); 
    rect.Y = rectScreen.Y; 

    if (rectScreen.Bottom > rect.Bottom) 
    rect.Height += (rectScreen.Bottom - rect.Bottom); 

    return rect; 
    } //然后这个屏幕区域设置给窗口:
    this.Bounds = this.GetAllScreenBounds();
      

  3.   

    怎么代码缩进也没了,重新贴一下设置窗口的大小为屏幕即可: //这个函数是用来获取屏幕的显示区域的,包括多显示器的 
    private Rectangle GetAllScreenBounds()
    {
        Rectangle rect = new Rectangle(0, 0, 0, 0);
        foreach (Screen screen in Screen.AllScreens)
        {
            Rectangle rectScreen = screen.Bounds;
            if (rectScreen.Left < rect.Left)
            {
                rect.Width += (rect.Left - rectScreen.Left);
                rect.X = rectScreen.X;
            }
            if (rectScreen.Right > rect.Right)
                rect.Width += (rectScreen.Right - rect.Right);
            if (rectScreen.Top < rect.Top)
            {
                rect.Height += (rect.Top - rectScreen.Top);
                rect.Y = rectScreen.Y;
            }
            if (rectScreen.Bottom > rect.Bottom)
                rect.Height += (rectScreen.Bottom - rect.Bottom);
        }
        return rect;
    } //然后在某个地方将这个屏幕区域设置给窗口: 
    this.Bounds = this.GetAllScreenBounds();注意:这个代码仅仅是设置全屏的,隐藏任务栏还是用你原来的代码
      

  4.   

    实现全屏效果://写在InitializeComponent();之后
    this.FormBorderStyle = FormBorderStyle.None;
    this.WindowState = FormWindowState.Maximized;
      

  5.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();            //这是你需要的代码
                this.FormBorderStyle = FormBorderStyle.None;
                this.ShowInTaskbar = false;
                this.WindowState = FormWindowState.Maximized;            //这是随便写写的代码
                Label lb = new Label();
                lb.Text = "这是你需要的效果,请按Alt+F4关闭";
                lb.TextAlign = ContentAlignment.MiddleCenter;
                lb.Dock = DockStyle.Fill;
                this.Controls.Add(lb);
            }
        }
    }
      

  6.   


    碰到问题了,不懂!有一个DataGrid 控件,总共有6列,第6列是模板列,且模板列里面放了一个LinkButton控件,ID是 LinkButton1,
    我想访问他,并操作他.我在 ItemDataBound事件中,我写成下面的形式,  LinkButton lbt2 = (LinkButton)e.Item.Cells[5].FindControl("LinkButton1");
            if (lbt2 != null)
            {
                lbt2.Text = "hello!";
                lbt2.Attributes.Add("onclick", "return confirm('kkek1')");
            }执行结果和预期的一样, LinkButton1  的 text 显示成了 "hello!",且在点击时有这个弹出提示;
    但是有一个问题是:在以上代码的 Cells[n]里面,n除了填5 以外, Cells[0]到 Cells[4]都能执行下在的语句,
    按理说只能是 第6列,就就是索引为5的才能执行下面的语句,现在出现了这样的情况,是怎么回事呢?难道是我对e.item.Cells[] 的理解有误吗?
    我的理解是:cell[]代表列或单元格的索引,控件是在第6列,就应该是 cells[5]