473,382 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Interacting with controls added at runtime

4
I have created a number of picture boxes and filled them with an image at runtime. The question is "How if possible can I create a click or double click event for those picture boxes?"

I am trying to be able to change the background from the available pictures in the picture boxes so I need a click event.


Thank you,


Keith Kelly
Aug 29 '07 #1
4 1036
Use WithEvents.

Expand|Select|Wrap|Line Numbers
  1. Public WithEvents MyPicControl As PictureBox
I should ask, how are you creating them @ runtime? From an existing control?
Aug 29 '07 #2
pureenhanoi
175 100+
I have created a number of picture boxes and filled them with an image at runtime. The question is "How if possible can I create a click or double click event for those picture boxes?"

I am trying to be able to change the background from the available pictures in the picture boxes so I need a click event.


Thank you,


Keith Kelly
Pls describe your problems more clearly
Aug 30 '07 #3
ncag
4
First, thank you for your replys.

Here is the code for creating the controls. Please be kind, I am not that proficient in VB but here it is.

I basically search a folder that has the pictures and then create appropriate picture boxes and load them with the image.

I have it in the Form_Load

Dim ctlname as vb.picturebox
Dim l as integer
Dim lfilename as string, lpic as picture
Dim pfolder as string, pextension as string, pwidth as long, pheight as long, pscalemode as long

pfolder = app.path & "\pictures\"
pextenstion = "*.jpg"
pwidth = 1000
pheight = 1000

getfilecount "path to pictures"

s = 0
l = 1000
do while s <> x
l = s * 1000
Set stlname = Form1.controls.add("vb.picturebox", "Pict" & s, Form1)
ctlname.visible = true
ctlname.width = 1000
ctlname.move 1, ctlname.width, 1000, 1000
s - s + 1

with ctlname
.borderstyle = 0
.width = ctlname.scalex(pwidth, pscalemode, ctlname.parent.scalemode)
.height = ctlname.scalex(pheight, pscalemode, ctlname.parent.scalemode)
.autoredraw = true
.scalemode = pscalemode
end with

lfilename = dir(pfolder & pextension)
Do while lfilename <> ""
set lpic = loadpicture(pfolder & lfilename)
ctlname.paintpicture lpic, 0, 0, pwidth, pheight
lfilename = Dir
if lfilename <> "" then
if s <> x then
exit do
end if
loop

Thanks

Keith Kelly
Aug 30 '07 #4
SammyB
807 Expert 512MB
Just do it like microsoft does at http://support.microsoft.com/kb/q190670/. HTH --Sam
Aug 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Eric | last post by:
I am in need of some advice on how to do the following: Have some type of container on form that would fill the visible area on screen (assuming the browser was maximized). I would like to...
4
by: Chuck Ritzke | last post by:
Hi, I've searched the newsgroup and other sources to understand how to handle runtime controls and see I'm not the only one who's confused, but I'm still not quite sure of the best way to handle...
1
by: Guadala Harry | last post by:
I will be creating a new ASPX that requires many controls to be inserted into the page at runtime. The controls include things like TextBox, RadioButtonList, CheckBoxList, DropDownList, etc....
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
0
by: anandv81 | last post by:
Hi, I encountered a strange problem while working on an application, the problem goes like this. I am generating a few textboxes at runtime at the server side and added to a placeholder, a...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
2
by: Rob | last post by:
I am not sure if this can be implemented.... There exists a TabContol (added at design time) to a form.. Tabs for this TabContol get added at run time. Usage of the following 2 properties...
2
by: =?Utf-8?B?VG9u?= | last post by:
Hello, I want to understand teh benefits of ajax technology. Does anyone has a good website where AJAX EXTENSIONS is worked out so I really understand it. There a 2 main questions: 1) How about...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.