MDI子窗体的字体设置的问题
这个问题已前提过,没有一个人回答,难道大家没有遇到过吗?
在主窗体中show一个子窗体,子窗体的label,button的字体属性想修改一下,不是默认的,但是只要我一改字体属性,在运行程序的时候,子窗体导入的时候就会出现算术溢出的错误,不知道这是为什么,难道是我的IDE有问题?大家没遇到过吗?
问题点数:100、回复次数:10Top
1 楼rottenapple(伪程序员)回复于 2002-10-22 21:04:22 得分 0
这个问题很难吗?微软的工程师们可否解答?Top
2 楼TheAres(班门斧)回复于 2002-10-22 21:06:21 得分 0
你帖子出来的时候,我就在我的计算机上试了,你的情况我没有办法在我机器上重现,不介意的话,把code贴上来。Top
3 楼yarshray(saga jion(心飘情落))回复于 2002-10-22 21:10:53 得分 0
我没遇见过,但你可以肯定这个字体有关吗???
Top
4 楼rottenapple(伪程序员)回复于 2002-10-27 13:12:44 得分 0
我觉得是的,因为我没有进行编码,
就是简单的拖了几个控件上去,如果字体选择默认的就可以,
如果在ide中更改属性,比如字体大小,就会出错
说是溢出的错误:(Top
5 楼TheAres(班门斧)回复于 2002-10-27 13:28:20 得分 0
是不是你VS .Net IDE的问题?
把你出错的code贴上来,我们试一试?Top
6 楼rottenapple(伪程序员)回复于 2002-11-05 20:17:48 得分 0
this.lblPlan.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));//这句话错误,就是多了个bold属性
this.lblPlan.Location = new System.Drawing.Point(153, 7);
this.lblPlan.Name = "lblPlan";
this.lblPlan.Size = new System.Drawing.Size(83, 18);
this.lblPlan.TabIndex = 0;
this.lblPlan.Text = "采购申请单";Top
7 楼ju_feng(NorthSky)回复于 2002-11-05 20:23:09 得分 10
??没有问题啊!Top
8 楼TheAres(班门斧)回复于 2002-11-06 20:20:41 得分 90
没有发现问题:
请测试我的代码:
/*---------------------------------------------------*/
//Form1.cs
/*---------------------------------------------------*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MDITest
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
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 Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem3});
this.menuItem1.Text = "File";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "New";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.Text = "Exit";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 278);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Form2 f2 = new Form2();
f2.MdiParent = this;
f2.Show();
}
}
}
/*---------------------------------------------------*/
//Form2.cs
/*---------------------------------------------------*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace MDITest
{
/// <summary>
/// Form2 的摘要说明。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form2()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(184, 64);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(96, 24);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(176, 120);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(96, 32);
this.label1.TabIndex = 1;
this.label1.Text = "lblPlan";
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1,
this.button1});
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));//这句话错误,就是多了个bold属性,这没错啊???
}
}
}
(over)
如果有问题,请将全部的代码贴上来.
Top
9 楼rottenapple(伪程序员)回复于 2002-11-10 11:37:43 得分 0
未处理的“System.ArithmeticException”类型的异常出现在 system.drawing.dll 中
其他信息:算术运算中发生溢出或下溢。
指向:
this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));//这句话错误,就是多了个bold属性,这没错啊???
这行。。。。看来是我的机器的问题?有没有可能是码的设置?Top
10 楼lbx1979(Love Arsenal)回复于 2002-11-10 12:05:52 得分 0
应该是你的机器问题了Top




