473,588 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Showing gaphics

I'm trying to dynamically add a picturebox control to a form.

I'm following some coding I see in the form designer generated code:
....and so far....nothing. Any help is appreciated.
Dim myPicture As New PictureBox()

With myPicture

myPicture = New System.Windows. Forms.PictureBo x()

..Visible = True

..Name = "NewPicture "

..Size = New System.Drawing. Size(64, 48)

'myPicture.Loca tion.X = new System.drawing

..TabStop = False

..Location = New System.Drawing. Point(700, 300)

..Image.FromFil e("c:\temp\holi day1.jpg")

..Show()

End With


Nov 20 '05 #1
22 1401
try this :
myForm.Controls .Add(myPicture)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Andy Chan" <an***********@ telus.net> wrote in message
news:OV******** ******@TK2MSFTN GP11.phx.gbl...
I'm trying to dynamically add a picturebox control to a form.

I'm following some coding I see in the form designer generated code:
...and so far....nothing. Any help is appreciated.
Dim myPicture As New PictureBox()

With myPicture

myPicture = New System.Windows. Forms.PictureBo x()

.Visible = True

.Name = "NewPicture "

.Size = New System.Drawing. Size(64, 48)

'myPicture.Loca tion.X = new System.drawing

.TabStop = False

.Location = New System.Drawing. Point(700, 300)

.Image.FromFile ("c:\temp\holid ay1.jpg")

.Show()

End With

Nov 20 '05 #2
Thanks for the hint. It didn't seem to work.

I'm looking around msdn.micrsoft.c om and www.devx.com. Don't suppose you'd
know of anywhere else that you'd recommend for source code? Thanks again.

"Crirus" <Cr****@datagro up.ro> wrote in message
news:Ow******** ******@TK2MSFTN GP09.phx.gbl...
try this :
myForm.Controls .Add(myPicture)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Andy Chan" <an***********@ telus.net> wrote in message
news:OV******** ******@TK2MSFTN GP11.phx.gbl...
I'm trying to dynamically add a picturebox control to a form.

I'm following some coding I see in the form designer generated code:
...and so far....nothing. Any help is appreciated.
Dim myPicture As New PictureBox()

With myPicture

myPicture = New System.Windows. Forms.PictureBo x()

.Visible = True

.Name = "NewPicture "

.Size = New System.Drawing. Size(64, 48)

'myPicture.Loca tion.X = new System.drawing

.TabStop = False

.Location = New System.Drawing. Point(700, 300)

.Image.FromFile ("c:\temp\holid ay1.jpg")

.Show()

End With


Nov 20 '05 #3
you can try to convert this C# sample... is quite easy

http://support.microsoft.com/default...;en-us;Q319266

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Andy Chan" <an***********@ telus.net> wrote in message
news:Oc******** *****@TK2MSFTNG P11.phx.gbl...
Thanks for the hint. It didn't seem to work.

I'm looking around msdn.micrsoft.c om and www.devx.com. Don't suppose you'd
know of anywhere else that you'd recommend for source code? Thanks again.

"Crirus" <Cr****@datagro up.ro> wrote in message
news:Ow******** ******@TK2MSFTN GP09.phx.gbl...
try this :
myForm.Controls .Add(myPicture)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Andy Chan" <an***********@ telus.net> wrote in message
news:OV******** ******@TK2MSFTN GP11.phx.gbl...
I'm trying to dynamically add a picturebox control to a form.

I'm following some coding I see in the form designer generated code:
...and so far....nothing. Any help is appreciated.
Dim myPicture As New PictureBox()

With myPicture

myPicture = New System.Windows. Forms.PictureBo x()

.Visible = True

.Name = "NewPicture "

.Size = New System.Drawing. Size(64, 48)

'myPicture.Loca tion.X = new System.drawing

.TabStop = False

.Location = New System.Drawing. Point(700, 300)

.Image.FromFile ("c:\temp\holid ay1.jpg")

.Show()

End With



Nov 20 '05 #4
As a hint: Try google with "add controls to forms at run-time NET VB", if
still cant make it work, you may find other exemples

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagro up.ro> wrote in message
news:Ow******** ******@TK2MSFTN GP09.phx.gbl...
try this :
myForm.Controls .Add(myPicture)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Andy Chan" <an***********@ telus.net> wrote in message
news:OV******** ******@TK2MSFTN GP11.phx.gbl...
I'm trying to dynamically add a picturebox control to a form.

I'm following some coding I see in the form designer generated code:
...and so far....nothing. Any help is appreciated.
Dim myPicture As New PictureBox()

With myPicture

myPicture = New System.Windows. Forms.PictureBo x()

.Visible = True

.Name = "NewPicture "

.Size = New System.Drawing. Size(64, 48)

'myPicture.Loca tion.X = new System.drawing

.TabStop = False

.Location = New System.Drawing. Point(700, 300)

.Image.FromFile ("c:\temp\holid ay1.jpg")

.Show()

End With


Nov 20 '05 #5
LOL, there is a VB version of it but didnt sow it... silly me

http://support.microsoft.com/default...b;EN-US;308433

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagro up.ro> wrote in message
news:u%******** ********@tk2msf tngp13.phx.gbl. ..
you can try to convert this C# sample... is quite easy

http://support.microsoft.com/default...;en-us;Q319266

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Andy Chan" <an***********@ telus.net> wrote in message
news:Oc******** *****@TK2MSFTNG P11.phx.gbl...
Thanks for the hint. It didn't seem to work.

I'm looking around msdn.micrsoft.c om and www.devx.com. Don't suppose you'd know of anywhere else that you'd recommend for source code? Thanks again.
"Crirus" <Cr****@datagro up.ro> wrote in message
news:Ow******** ******@TK2MSFTN GP09.phx.gbl...
try this :
myForm.Controls .Add(myPicture)

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Andy Chan" <an***********@ telus.net> wrote in message
news:OV******** ******@TK2MSFTN GP11.phx.gbl...
> I'm trying to dynamically add a picturebox control to a form.
>
> I'm following some coding I see in the form designer generated code:
> ...and so far....nothing. Any help is appreciated.
> Dim myPicture As New PictureBox()
>
> With myPicture
>
> myPicture = New System.Windows. Forms.PictureBo x()
>
> .Visible = True
>
> .Name = "NewPicture "
>
> .Size = New System.Drawing. Size(64, 48)
>
> 'myPicture.Loca tion.X = new System.drawing
>
> .TabStop = False
>
> .Location = New System.Drawing. Point(700, 300)
>
> .Image.FromFile ("c:\temp\holid ay1.jpg")
>
> .Show()
>
> End With
>
>
>
>



Nov 20 '05 #6
* "Andy Chan" <an***********@ telus.net> scripsit:
I'm looking around msdn.micrsoft.c om and www.devx.com. Don't suppose you'd
know of anywhere else that you'd recommend for source code? Thanks again.


<http://groups.google.c om>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #7
Cor
Hi Andy,
What is the size of your form

.Location = New System.Drawing. Point(700, 300)

Can it be that you paint it beside your form?

And you need in my opinion that Add that Crirus stated.

Cor
Nov 20 '05 #8
Hi Andy,

You're right to use the code that the Form Designer creates but you have
to do it carefully (like Crirus's Controls.Add) - and know which bits to do
differently - like Image.

The Designer uses embedded resources which is not what you want. You
spotted that so you used

myPicture.Image .FromFile("c:\t emp\holiday1.jp g")

Unfortunately this loads an image and then throws it away because it's not
being assigned to anything. The use of myPicture doesn't mean that it updates
myPicture!

The bit that you're missing is <setting> the Image.

myPicture.Image = Image.FromFile ("c:\temp\holid ay1.jpg")

Regards,
Fergus

Nov 20 '05 #9
Image.FromFile is a shared function which will return a new Image based on
the file. Being shared, it doesn't have an Image instance to load the file
into, so it won't change the Image who's reference you used to call the
function. Your code isn't assigning the returned image to the Image
property of your PictureBox.

Try replacing this line:
.Image.FromFile ("c:\temp\holid ay1.jpg")

With this line:
.Image = Image.FromFile( "c:\temp\holida y1.jpg")

I think that your code to create and display the PictureBox is working just
fine, it just doesn't have an image to display. You do need to add the
picturebox to the form's control collection though (as mentioned in another
post).

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7326
by: Vishnu | last post by:
I have a strange problem on WindowsXP proffessional with IE6 ,when i try to display a tiff file ,it is not showing ,small red x is comming up. I tried by dowloading latest IE from microsoft but no use. This is working fine on win2k IE6 Here is the html file I am using to display the tif file <html> <head>
2
2216
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups of searchable fields in the fields 3. Each group can be expanded/collapsed by clicking on a link "(Fewer|More) Options" which sits right next to the group title.
3
3070
by: Brian Henry | last post by:
Is there anyway to prevent the white box that drops down when you do a combobox dropdown from showing? I am trying to make a custom combobox which requires showing a custom form in its place, but the white box shows up still ontop of the new form that is taking its palce even though there is no items in the white box. Any windows messages or anything you can trap or whatnot? thanks!
1
840
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called AutoGenerateColumns. The default value is "True". This means that when AutoGenerateColumns is set to True,...
0
1227
by: ikhan | last post by:
Hello, I am using an activex control on my website. It was running fine with framework 1.1, when I try to run it on framework 2.0 it's not showing up. It's not showing any error message, just a "image not found icon" in webpage's body and "DONE" on IE's status bar. When switch it to framwork 1.1 it runs fine. What I think for the activeX not showing issue is that this might be some security issue because I had the same problem earlier...
10
2149
by: bessington | last post by:
hey all, i'm having a rather bizarre problem.. the image tag i have declared in my xhtml is not showing in safari / konqueror but showing just fine in Firefox, IE, Opera... this is a complete mystery and I have been scouring every book / resource I can find but haven't come up with an answer. any one have any ideas? all other images in site showing fine - but they are declared as background images in the css. the site is:...
15
2679
missinglinq
by: missinglinq | last post by:
I'd like to use acCmdAppMinimize with two forms on the screen at once. Currently, if I have a form opening the db (with DoCmd.Maximize in the OnLoad event) and then a popup form on top of the first form, the first form vanishes when the second form appears. Alternatively, I like to have both showing with just the Access container showing, with no native menus showing. Unchecking everything in Startup gets rid of everythinh except File - Edit...
3
3358
by: Torben Laursen | last post by:
I have a COM shared add-in written in C# that I use in Excel. One of the thinks that the user can do is to open some winforms. The problem that I have is that the first time the user opens a winform it is slow around 7 seconds and after that it takes no time. Is there a way to speed up the process to show the winform the first time? Thanks Torben
6
2765
by: ajk | last post by:
Hi I was wondering how to show different properties in design and run-mode for a user control? Is it possible to do this when implementing the System.ComponentModel.ICustomTypeDescriptor interface? e.g. when selecting the control from a toolbox with controls other properties show up when the program is in design mode than in run mode.
6
4173
by: painkiller | last post by:
language: vb.net environment: windows forms .net : v1.1 i am having a checkedlistbox control that display document category such as text, image, video, audio etc. these values are coming from database. when a user clicks any of the above values and saves the form, the item's "value" is getting saved in database. and when a user logs back in, his/her previously checked value items should be shown as checked. Everything is working fine...
0
7929
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7862
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6634
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5729
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1459
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.