表格背景图像消失 [英] Form Background Image Disappears
问题描述
我使用以下代码获取表单的背景图片
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理mnuBgroundImage。 Clic
如果OpenFileDialog1.ShowDialog()= DialogResult.OK
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName
Me .BackgroundImage = Image.FromFile(OpenFileDialog1.FileName
sr.Close(
End I
End Su
这很好用。但是,这是在frmMain上,当我切换到form2然后返回到frmMain时,背景图像消失了。我在这里缺少什么
谢谢
John
I am using the following code to get a background image for my form
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuBgroundImage.Clic
If OpenFileDialog1.ShowDialog() = DialogResult.OK The
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName
Me.BackgroundImage = Image.FromFile(OpenFileDialog1.FileName
sr.Close(
End I
End Su
This works great. However, this is on frmMain and when I switch to form2 and then return to frmMain the background image is gone. What am I missing here
Thank you
John
推荐答案
*" =?Utf-8?B?amNyb3VzZQ ==?="< an*******,discussions.microsoft.com> scripsit:
* "=?Utf-8?B?amNyb3VzZQ==?=" <an*******@discussions.microsoft.com> scripsit:
我使用以下代码获取表单的背景图片:
私有子mnuBgroundImage_Click(BYVAL sender As System.Object,ByVal e As System.EventArgs)处理mnuBgroundImage.Click
如果OpenFileDialog1.ShowDialog()= DialogResult.OK然后
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
Me.BackgroundImage = Image.FromFile(OpenFileDialog1.FileName)
sr.Close()
结束如果
结束子
这很好用。但是,这是在frmMain上,当我切换到form2然后返回到frmMain时,背景图像消失了。我在这里缺少什么?
I am using the following code to get a background image for my form:
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuBgroundImage.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
Me.BackgroundImage = Image.FromFile(OpenFileDialog1.FileName)
sr.Close()
End If
End Sub
This works great. However, this is on frmMain and when I switch to form2 and then return to frmMain the background image is gone. What am I missing here?
你如何切换并返回?两个表格在同一时间或者一个接一个的时间内可见吗?
-
Herfried K. Wagner [ MVP]
< URL:http://dotnet.mvps.org/>
How do you "switch and return"? Are the two forms visible at the same
time or one after the other?
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
>
如果您不使用它,为什么要创建流阅读器?为什么不这样做?b $ b你尝试这样的事情吗?
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object,ByVal
$ b $是
As System.EventArgs)处理mnuBgroundImage.Click
如果OpenFileDialog1.ShowDialog()= DialogResult.OK那么
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
Dim bm as new Bitmap(sr)
sr.Close()
Me.BackgroundImage = bm
结束如果
结束子
肯
---- ---------
" jcrouse" <一个******* @ discussions.microsoft.com>在消息中写道
新闻:2F ********************************** @ microsof t.com:
Hi,
Why are you creating a stream reader if you are not using it? Why don''t
you try something like this?
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object, ByVal
e
As System.EventArgs) Handles mnuBgroundImage.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
Dim bm as new Bitmap(sr)
sr.Close()
Me.BackgroundImage = bm
End If
End Sub
Ken
-------------
"jcrouse" <an*******@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com:
我使用以下代码获取表单的背景图片:
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object,ByVal e
As System.EventArgs)处理mnuBgroundImage.Click
如果OpenFileDialog1.ShowDialog()= DialogResult.OK然后
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
我。 BackgroundImage = Image.FromFile(OpenFileDialog1.FileName)
sr.Close()
结束如果
结束子
这很好用。但是,这是在frmMain上,当我切换到form2
然后返回到frmMain时,背景图像消失了。我在想什么?
谢谢你,
约翰
I am using the following code to get a background image for my form:
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles mnuBgroundImage.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
Me.BackgroundImage = Image.FromFile(OpenFileDialog1.FileName)
sr.Close()
End If
End Sub
This works great. However, this is on frmMain and when I switch to form2
and then return to frmMain the background image is gone. What am I missing
here?
Thank you,
John
-
发送邮件已通过无病毒验证。
由AVG Anti-Virus检查( http://www.grisoft.com)。
版本:7.0.230 /病毒数据库:263.0.0 - 发布日期:2004年2月2日
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004
可能是因为我不知道自己在做什么。当我使用你的代码时
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object,ByVal e
As System.EventArgs)处理mnuBgroundImage.Clic
如果OpenFileDialog1.ShowDialog()= DialogResult.OK
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName
Dim bm作为新的位图(sr
sr.Close(
Me.BackgroundImage = b
结束我
结束Su
它不喜欢线条Dim bm as New Bitmap(sr)。它强调了sr并说了很多关于不能转换自...到...
更多想法
Joh
Probably because I have no idea what I am doing. When I use your code
Private Sub mnuBgroundImage_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles mnuBgroundImage.Clic
If OpenFileDialog1.ShowDialog() = DialogResult.OK The
Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName
Dim bm as new Bitmap(sr
sr.Close(
Me.BackgroundImage = b
End I
End Su
It doesn''t like the line "Dim bm as New Bitmap(sr)". It underlines the "sr" and says a lot about can''t convert from ... to ..
Any more ideas
Joh
这篇关于表格背景图像消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!