C#窗体滚动条问题

Bitmapbmap=newBitmap(1300,900);Graphicsgph=Graphics.FromImage(bmap);我画了一个图长1300高900我的... Bitmap bmap = new Bitmap(1300, 900);
Graphics gph = Graphics.FromImage(bmap);
我画了一个图 长1300高900

我的窗体必须长高必须是 580,580

但是要让窗体带滚动条怎么弄 高手指点下
展开
 我来答
旋天渣观9129
2008-09-15 · TA获得超过1487个赞
知道大有可为答主
回答量:1443
采纳率:0%
帮助的人:1648万
展开全部
可以加个PictureBox,然后把图片放到里面.再把窗体的AutoScroll 设成true
Bitmap bmap = new Bitmap(1300, 900);
Graphics gph = Graphics.FromImage(bmap);
gph.DrawLine(new Pen(Color.Blue), 0, 0, 100, 100);
PictureBox pb = new PictureBox();
pb.Image = bmap;
pb.Size = bmap.Size;
this.Controls.Add(pb);
this.AutoScroll = true;
冰封少尉
2008-09-15 · TA获得超过486个赞
知道小有建树答主
回答量:529
采纳率:0%
帮助的人:478万
展开全部
progressbar不是一个滚动条的控件吗,直接用算了.如果你要用LEFT WIDTH来算也可以,可以控制窗体大小啊
在load事件里
this.maxsize=new size(580,580);
this.minsize=new size(580,580);
这样就OK了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
Narvik小红帽
2008-09-15 · TA获得超过649个赞
知道小有建树答主
回答量:549
采纳率:0%
帮助的人:559万
展开全部
这个有点麻烦的

加个滚动条,在它的事件里掉用Invalid...方法(方法名忘了~:P)

然后重写OnPaint方法
在方法里根据滚动条的值,在窗体上画一部分图片(具体画哪部分要根据窗体大小和滚动条的值进行计算),造成滚动的效果

在《C#高级编程》上有例子,以前做的,记不清了~
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
德甲邵大傻
2008-09-15 · 超过61用户采纳过TA的回答
知道答主
回答量:159
采纳率:0%
帮助的人:0
展开全部
给你个例子,图片名字和窗口尺寸自己换掉
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

public class Sizer : System.Windows.Forms.Form {
private System.Windows.Forms.PictureBox picCritter;
private System.Windows.Forms.HScrollBar scrSize;

public static void Main(){
Application.Run(new Sizer());
}
public Sizer() {
InitializeComponent();
}
private void InitializeComponent() {
this.picCritter = new System.Windows.Forms.PictureBox();
this.scrSize = new System.Windows.Forms.HScrollBar();
this.SuspendLayout();

this.picCritter.BackColor = System.Drawing.Color.White;
this.picCritter.Image = new Bitmap("winter.jpg");
this.picCritter.Location = new System.Drawing.Point(8, 8);
this.picCritter.Name = "picCritter";
this.picCritter.Size = new System.Drawing.Size(40, 40);
this.picCritter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picCritter.TabIndex = 0;
this.picCritter.TabStop = false;

this.scrSize.Location = new System.Drawing.Point(16, 248);
this.scrSize.Maximum = 200;
this.scrSize.Minimum = 50;
this.scrSize.Name = "scrSize";
this.scrSize.Size = new System.Drawing.Size(256, 16);
this.scrSize.TabIndex = 1;
this.scrSize.Value = 50;
this.scrSize.Scroll += new System.Windows.Forms.ScrollEventHandler(this.scrSize_Scroll);

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.scrSize,
this.picCritter});
this.Name = "Sizer";
this.Text = "Sizer";
this.ResumeLayout(false);

}

private void scrSize_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) {
picCritter.Size = new Size(scrSize.Value, scrSize.Value);
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式