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 22 1406
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
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
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
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
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 > > > >
* "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>
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
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
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). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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>
|
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.
|
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!
|
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,...
|
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...
| |
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:...
|
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...
|
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
|
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.
|
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...
|
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...
| |
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,...
|
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |