I need add one new unknown control at runtime and the only one information
that i have is one string with type of control.
Example:
c = "System.Windows .Forms.TextBox"
How i can create one textbox at runtime in my form1? 7 2427
Take a look at System.Reflecti on namespace.
It should get you started.
"José Teixeira Junior" <te************ *@stinfo.com.br > wrote in message
news:Op******** ******@TK2MSFTN GP11.phx.gbl... I need add one new unknown control at runtime and the only one information that i have is one string with type of control.
Example: c = "System.Windows .Forms.TextBox"
How i can create one textbox at runtime in my form1?
-----Original Message----- I need add one new unknown control at runtime and the
only one informationthat i have is one string with type of control.
Example: c = "System.Windows .Forms.TextBox"
How i can create one textbox at runtime in my form1?
.
Hi José
Here is a code sample that will add a text box to your
current form.
Dim objText As TextBox = New TextBox 'Create text control
objText.Visible = True 'Make it visible
objText.Name = "myText"
objText.Locatio n = New Point(10, 10) 'Set the x=10 and y
= 10
objText.Height = 20
objText.Width = 200
objText.Text = "Hello!"
Me.Controls.Add (objText) 'add text to current form
Just cut and past this code sample inside a button click
event and you should see a text box.
Good luck,
Claude
Hi Claude,
Thanks for you help, but, i don't know the type of my control in advance.
I'm sweeping a collection that contains more values of controls.
As result, i have:
For i = 0 to colControls.Cou nt - 1
strControl = colControls(i). StringControl
Next
In this point, i need to create control starting from the string strControl.
Alerts:
strControl as string
colControls as my collection (can't modify your structure because it is a
external collection - other component that is not on my control)
Then, who can help me?
"Claude Froment" <cl************ @rogers.com> escreveu na mensagem
news:14******** *************** *****@phx.gbl.. . -----Original Message----- I need add one new unknown control at runtime and the
only one informationthat i have is one string with type of control.
Example: c = "System.Windows .Forms.TextBox"
How i can create one textbox at runtime in my form1?
.
Hi José
Here is a code sample that will add a text box to your
current form.
Dim objText As TextBox = New TextBox 'Create text control
objText.Visible = True 'Make it visible
objText.Name = "myText"
objText.Locatio n = New Point(10, 10) 'Set the x=10 and y
= 10
objText.Height = 20
objText.Width = 200
objText.Text = "Hello!"
Me.Controls.Add (objText) 'add text to current form
Just cut and past this code sample inside a button click
event and you should see a text box.
Good luck,
Claude
Fergus help me in microsoft.publi c.dotnet.langua ges.vb.
Thanks everybody.
Morpheu
"Morpheu" <mo*****@hotmai l.com> escreveu na mensagem
news:u4******** ******@TK2MSFTN GP12.phx.gbl... Hi Claude,
Thanks for you help, but, i don't know the type of my control in advance. I'm sweeping a collection that contains more values of controls.
As result, i have:
For i = 0 to colControls.Cou nt - 1 strControl = colControls(i). StringControl Next
In this point, i need to create control starting from the string
strControl. Alerts: strControl as string colControls as my collection (can't modify your structure because it is a external collection - other component that is not on my control)
Then, who can help me?
"Claude Froment" <cl************ @rogers.com> escreveu na mensagem news:14******** *************** *****@phx.gbl.. .
-----Original Message----- I need add one new unknown control at runtime and the only one informationthat i have is one string with type of control.
Example: c = "System.Windows .Forms.TextBox"
How i can create one textbox at runtime in my form1?
. Hi José
Here is a code sample that will add a text box to your current form. Dim objText As TextBox = New TextBox 'Create text control objText.Visible = True 'Make it visible objText.Name = "myText" objText.Locatio n = New Point(10, 10) 'Set the x=10 and y = 10 objText.Height = 20 objText.Width = 200 objText.Text = "Hello!" Me.Controls.Add (objText) 'add text to current form Just cut and past this code sample inside a button click event and you should see a text box. Good luck, Claude
Hi Guys,
Just in case you're interested, I'll save you the trek to languages.vb.
The following will create a Control given a name such a "Button".
Public Function MakeControl (sTypeName As String) As Control
Dim sFormTypeName As String = GetType (Form).Assembly QualifiedName
sTypeName = sFormTypeName.R eplace ("Form,", sTypeName & ",")
Dim oType As Type = Type.GetType (sTypeName)
Return DirectCast (Activator.Crea teInstance (oType), Control)
End Function
This was given in answer to a similar query a week ago. For an explanation
of how it works, see http://tinyurl.com/r393
Regards,
Fergus
Fergus Cooney <fi******@tesco .net> wrote: Just in case you're interested, I'll save you the trek to languages.vb.
The following will create a Control given a name such a "Button".
Public Function MakeControl (sTypeName As String) As Control Dim sFormTypeName As String = GetType (Form).Assembly QualifiedName sTypeName = sFormTypeName.R eplace ("Form,", sTypeName & ",") Dim oType As Type = Type.GetType (sTypeName) Return DirectCast (Activator.Crea teInstance (oType), Control) End Function
This was given in answer to a similar query a week ago. For an explanation of how it works, see http://tinyurl.com/r393
That looks complicated and slightly tricksy to me.
You can make the code simpler than that:
Dim formsAssembly as Assembly = GetType (Form).Assembly
Dim oType as Type = formsAssembly.G etType _
("System.Window s.Forms."& sTypeName)
Return DirectCase (Activator.Crea teInstance (oType), Control)
There's no need to start replacing bits of the type name - just find
out which assembly the type should be in, and fetch it directly from
that.
I'd personally make the parameter the fully qualified type name
(without the assembly, but with the namespace), at which point the
middle line is just
Dim oType as Type = formsAssembly.G etType(sTypeNam e)
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi Jon,
That was produced by trial and error and MSDN. I know Types better than I
do Assembly.
Thank you. I have a bit more balance. ;-)
Regards,
Fergus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: José Teixeira Junior |
last post by:
I need add one new unknown control at runtime and the only one information
that i have is one string with type of control.
Example:
c = "System.Windows.Forms.TextBox"
How i can create one textbox at runtime in my form1?
|
by: DJ Dev |
last post by:
Hi All,
I would like to add the <div> tag programatically from the code-behind
of my aspx file. Basically, I would like to a table to this <div>.
There are a number of tables which are created dynamically in the
code-behind. Each table should go to its own <div> tag.
The reason that I can't have the <div> tags in aspx is that the number
of the tables is unknown until runtime and each table should go into
its own <div> tag.
How is this...
|
by: MattB |
last post by:
Hello. I'm creating a page to edit a person's record (name address, etc)
using a DataGrid. I want the fields that can be edited to be created at
runtime based on a list of columns in web.config. This is working fine,
and I can add a control (TextBox or DropDownList) dynamically for the
user to fill in a value. This works well for just adding controls for
data entry.
Now, I want to add validators on the fly as well and it not going quite...
|
by: Lars-Erik Aabech |
last post by:
Hi!
Guess it's my day again.. Tried to deploy a test release of a new asp.net
web today, and got a terrible error.
The web is running swell on three development computers, but when it's
copied to the test server it won't work at all.
Looks like aspnet_wp is trying to compile it for five seconds, then it stops
working what so ever. The system event log gets the following entry:
Application popup: aspnet_wp.exe - Application Error : The...
|
by: José Teixeira Junior |
last post by:
Hi,
How i can add one new unknown control at runtime in my form1?
Thaks.
| |
by: Morpheu |
last post by:
Hello,
I have other problem with the unknown control added at runtime:
When i use a mdiformchild, the control don't appear.
In a normal form, it works.
Somebody?
Thank you in advance.
Morpheu
|
by: rushikesh.joshi |
last post by:
Hi All,
I have created my own WebControl and want to add it in my aspx page at
runtime.
it's compiling perfectly, but when i m going to execute, it gives me
error of "Object reference not set to an instance of an object." in my
server control (ascx.cs file)
|
by: sonic |
last post by:
I am trying to dynamically load a validator and must be missing
something elementary here.
I extended TextBox control to add some functionality to it. One new
feature it contains is IsRequired property. if true, the control will
render it self differently, and should add a RequiredFiledValidator
control to the page.
so in my controls render event, i am adding the following:
|
by: Pete Kane |
last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would
contain tab pages of my own classes, I know you can achieve this with ListView columns so it should be doable, thanks
|
by: John |
last post by:
Hi Everyone,
I'm having this extremely annoying problem with Internet Explorer 6,
giving me an error message saying "unknown runtime error" whenever I
try to alter the contents of a <divelement using innerHTML.
Now, I've researched this problem on the web, and found many references
to it, but none of them quite addressed my specific situation, and
since my experience with JavaScript is limited, I was not able to adapt
the solutions I...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: 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...
| |