请问怎样让一个form有垂直滚动条和水平滚动条?

howtofind 2003-10-21 01:13:14
是关于main form的,谢谢.
...全文
832 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
howtofind 2003-10-21
  • 打赏
  • 举报
回复
up
howtofind 2003-10-21
  • 打赏
  • 举报
回复
谢谢各位,我试过了,还是不行,我的整个代码是这样的:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication15
{

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;

private System.ComponentModel.Container components = null;
Control control;

public Form1()
{

InitializeComponent();

}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();

this.button1.Location = new System.Drawing.Point(208, 80);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(292, 270);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
Graphics graphics2 =CreateGraphics();
Image newImage1 = Image.FromFile("c:\\Capturess.bmp");
Point ulCorner = new Point( 0, 0);
graphics2.DrawImage(newImage1, ulCorner);
}
}
}
三杯倒 2003-10-21
  • 打赏
  • 举报
回复
[C#]
private void DisplayMyScrollableForm()
{
// Create a new form.
Form form2 = new Form();
// Create a button to add to the new form.
Button button1 = new Button();
// Set text for the button.
button1.Text = "Scrolled Button";
// Set the size of the button.
button1.Size = new Size(100,30);
// Set the location of the button to be outside the form's client area.
button1.Location = new Point(form2.Size.Width + 200, form2.Size.Height + 200);

// Add the button control to the new form.
form2.Controls.Add(button1);
// Set the AutoScroll property to true to provide scrollbars.
form2.AutoScroll = true;

// Display the new form as a dialog box.
form2.ShowDialog();
}
Alton1981 2003-10-21
  • 打赏
  • 举报
回复
若控件的size比窗体的size大,窗体会自动添加垂直滚动条和水平滚动条
shajie 2003-10-21
  • 打赏
  • 举报
回复
设置form的AutoScroll属性为True
当控件被放置在窗体的工作区域之外时,滚动条会自动出现

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧