c#中picture控件Box控件位置的移动

datagridview 点击一行数据 显示图片在PictureBox控件中。如何实现。用C#!!
datagridview 点击一行数据 显示图片在PictureBox控件中。如何实现。用C#!! 30
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e){string path=dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells["path"].Value.ToString() ;}private void dataGridview1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e){if (dataGridview1.Columns[e.ColumnIndex].Name.Equals("Image")){string path = e.Value.ToString();e.Value = GetImage(path);}} public System.Drawing.Image GetImage(string path){System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open);System.Drawing.Image result = System.Drawing.Image.FromStream(fs); fs.Close();
}有什么问题吗?
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e){string path=dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells["path"].Value.ToString() ;System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open);图片控件.Image= System.Drawing.Image.FromStream(fs); fs.Close(); }
若希望程序更健壮,可以给图片读取套上try
那图片的路径是放哪里的?
string path=dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells
你的第一行代码取的不是路径吗?
运行有问题
貌似懂了。。是不是要在数据库里加Path的列?在Path列里写图片路径?
的感言:非常感谢! 相关知识
其他回答 (1)
楼主,你好
有些控件是不符合硬盘的,所以才会出现上面的情况,建议你找一个电脑程序者、帮你解决问题。
如果有帮到你的、请采纳为答案、谢谢、QQ
相关知识等待您来回答
编程领域专家C#中picturebox控件如何对图像进行拖拽_百度知道
C#中picturebox控件如何对图像进行拖拽
提问者采纳
int width = 200.DrawImage(JPEG.CreateGraphics().Y =// g.F this.Y.F g,本人已经测试过, EventArgs e) { Graphics g = private void pictureBox1_MouseMove( int height = 100; } int driftX = 0, MouseEventArgs e) { pictureBox1.pictureBox1_MouseMove), driftY = 0.D c, my).MouseDown += new System.Y;/ mx = mx - driftX, MouseEventArgs e) { pictureBox1.FromFile(@&quot.Dispose().pictureBox1; Graphics g = pictureBox1.Y.Windows.X.MouseEventHandler(定义外接矩形的左上角坐标和高度及宽度 int y = 15;&#47.jpg& my = my - driftY, rect): Form { public Form1() { InitializeComponent();按下鼠标时.Y = e.Cursor = C / } } } private void Form1_Load(object sender, my = 0; private void pictureBox1_MouseUp( foreach (Control c in this.Clear(pictureBox1.X =/定义矩形 p.pictureBox1;松开鼠标时.X -&#47.FillRectangle(BlueB/ g.Image = Image,形状恢复为箭头 wselected = Rectangle rect = new Rectangle(x.Image).Cursor = C&#47.X;E:&#92:public partial class Form1 .MouseMove += new System.D生成图形对象 SolidBrush BlueBrush = new SolidBrush(C); int mx = 0; p,将鼠标形状改为手型 wselected = true.W Bitmap JPEG = new Bitmap(/ driftY = p,&#47.Cursor = Cursors.Y -填充矩形 } bool wselected = JPEG;&#47.pictureBox1;&#47.MouseEventHandler( Point p = new Point().BackColor).pictureBox1_MouseDown).Dispose(); /图像移动的距离 } } private void pictureBox1_MouseDown(object sender.X = e.X, height); } private void button1_Click(object sender, EventArgs e) { this.Blue), y.CreateGraphics();生成填充用的画刷 int x = 15下面这个代码可以实现, MouseEventArgs e) { if (wselected) { driftX =&#47.Hand,Images&#92.Controls) { if (c is PictureBox) {&#47
其他类似问题
16人觉得有用
picturebox的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁C#中PictureBox、Timer控件(动态的窗体)
利用PictureBox、Timer控件,做一个动态的窗体。在窗体中有四个picturebox控件,分别实现上下左右四个方向的移动。
(1)窗体设计
(2)代码编写
using System.Collections.G
using System.D
using System.D
using System.L
using System.T
using System.Windows.F
namespace xm4
&&& public
partial class Form1 : Form
public Form1()
&&&&&&&&&&&
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
&&&&&&&&&&&
timer1.Enabled =
private void button2_Click(object sender, EventArgs e)
&&&&&&&&&&&
timer1.Enabled =
private void button3_Click(object sender, EventArgs e)
&&&&&&&&&&&
this.Close();
private void timer1_Tick(object sender, EventArgs e)
&&&&&&&&&&&
if (pictureBox1.Left & this.Width)
&&&&&&&&&&&&&&&
pictureBox1.Left = 0;
&&&&&&&&&&&
&&&&&&&&&&&&&&&
pictureBox1.Left += 5;
&&&&&&&&&&&
if (pictureBox2.Left & 0)
&&&&&&&&&&&&&&&
pictureBox2.Left = W
&&&&&&&&&&&
&&&&&&&&&&&&&&&
pictureBox2.Left -= 5;
&&&&&&&&&&&
if (pictureBox3.Top& this.Bottom)
&&&&&&&&&&&&&&&
pictureBox3.Top = 0;
&&&&&&&&&&&
&&&&&&&&&&&&&&&
pictureBox3.Top += 5;
&&&&&&&&&&&
if (pictureBox4.Top & 0)
&&&&&&&&&&&&&&&
pictureBox4.Top = B
&&&&&&&&&&&
&&&&&&&&&&&&&&&
pictureBox4.Top -= 5;
private void Form1_Load(object sender, EventArgs e)
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。汇聚2000万达人的兴趣社区下载即送20张免费照片冲印
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(3104)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'C#保存PictureBox控件框中所绘图画的方法',
blogAbstract:'using S using System.Collections.G ponentM using System.D using System.D using System.Drawing.I using System.T using System.Windows.F namespace testsaveimage { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int i = 5;//画线用的 ',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:6,
publishTime:0,
permalink:'blog/static/',
commentCount:1,
mainCommentCount:1,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 picturebox控件 的文章

 

随机推荐