文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>windows mobile 的控件大小不改变的问题

windows mobile 的控件大小不改变的问题

时间:2010-11-06  来源:龙ML

要用到自定义的控件,但是,刚开始,这个空CustomControl,不能达到240x320的大小…

无论怎么调整,都是200x200 的大小。

但是断点看到的确实已经有赋值240x320 的动作了

这是为什么捏?

现在已经解决了!其实很简单。不过原理是什么我不清楚。

下面是我的代码!大家可以看看

namespace textboxP
{
    partial class CustomControl2
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary>
        /// 设计器支持所需的方法 -  代码都可以写在这里 

        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            components = new System.ComponentModel.Container();
            btn_button1 = new bigo10.PictureButton();
            btn_button1.Size = new System.Drawing.Size(this.Size.Width / 2, this.Height / 4);//随便写的。做测试而已
            btn_button1.Location = new System.Drawing.Point(0, 20);
            this.Controls.Add(btn_button1);

            panel1 = new System.Windows.Forms.Panel();
            panel1.Size = this.Size;
            panel1.BackColor = System.Drawing.Color.Gray;
            panel1.Location = new System.Drawing.Point(0,0);
            this.Controls.Add(panel1);

            this.Resize += new System.EventHandler(CustomControl2_Resize);
            this.Paint += new System.Windows.Forms.PaintEventHandler(CustomControl2_Paint);
        }

        void CustomControl2_Resize(object sender, System.EventArgs e)//这个就是解决的关键
        {
            panel1.Size = this.Size;//控件在form1的designer.cs里面已经赋值成240x320的大小。resize,在控件大小调整的时候,会自动调整当前panel1.的size。
        }

        void CustomControl2_Paint(object sender, System.Windows.Forms.PaintEventArgs e)//当前测试的自定义控件的重绘,仅仅是改变颜色,便于区分而已
        {
            System.Drawing.Graphics g = e.Graphics;
            g.Clear(System.Drawing.Color.Red);
            g.Dispose();//GDI对象,用完了最好记得释放掉
        }
       
        public bigo10.PictureButton btn_button1; //这里是我定义的一个button,可以添加图片做背景,也可以有按下时候的图片变化
        public System.Windows.Forms.Panel panel1;//系统的panel
        #endregion
    }
}

 

 

相关阅读 更多 +
排行榜 更多 +
方块枪战战场安卓版

方块枪战战场安卓版

飞行射击 下载
战斗火力射击安卓版

战斗火力射击安卓版

飞行射击 下载
空中防御战安卓版

空中防御战安卓版

飞行射击 下载