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

Home Posts Topics Members FAQ

dynamic contols

hi...im looking for a example of
creating controls on the fly (run time)
or a pre-created control i can copy or inherit
textbox, label, buttons

tks
MJ

Jul 27 '07 #1
4 1315
very simple on a Form:

Button btn = new Button();
btn.Text = "Click me";
btn.Click += delegate {this.Text = "Hi";}; // or an existing
SomeMethod(obje ct, EventArgs)
Controls.Add(bt n);

Is there something more specific you want to do?

Marc

Jul 27 '07 #2
MikeJ,

Creating controls are like any other object, in the sense that you
create an instance, and set it's properties.

As a matter of fact, the VS.NET designer doesn't do anything special
when you set the properties of your controls, it actually emits code. It is
not declarative, like say, XAML is. You could use the designer generated
code as an example.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"MikeJ" <ve***********@ sbcglobal.netwr ote in message
news:td******** ***********@new ssvr29.news.pro digy.net...
hi...im looking for a example of
creating controls on the fly (run time)
or a pre-created control i can copy or inherit
textbox, label, buttons

tks
MJ

Jul 27 '07 #3
That's all I do: I create a new form, arrange the controls I want on
the screen, then look at the code that Visual Studio generated.

On Jul 27, 7:44 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
MikeJ,

Creating controls are like any other object, in the sense that you
create an instance, and set it's properties.

As a matter of fact, the VS.NET designer doesn't do anything special
when you set the properties of your controls, it actually emits code. It is
not declarative, like say, XAML is. You could use the designer generated
code as an example.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om

"MikeJ" <vettes_n_j...@ sbcglobal.netwr ote in message

news:td******** ***********@new ssvr29.news.pro digy.net...
hi...im looking for a example of
creating controls on the fly (run time)
or a pre-created control i can copy or inherit
textbox, label, buttons
Jul 27 '07 #4
Thanks for the Answer...thats all i needed....
MJ

"MikeJ" <ve***********@ sbcglobal.netwr ote in message
news:td******** ***********@new ssvr29.news.pro digy.net...
hi...im looking for a example of
creating controls on the fly (run time)
or a pre-created control i can copy or inherit
textbox, label, buttons

tks
MJ

Jul 27 '07 #5

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

Similar topics

0
483
by: Mark | last post by:
I have a "Tabbed" ASP.NET page. When a user clicks on a tab, i want the corresponsing dynamic control to be loaded. This works great except that the postbacks on that dynamically loaded control do not work the first time they are attempted. Every subsequent attemp works great. Here is what is happening private void Page_Load(object sender, System.EventArgs e) { LoadContentControl();
6
1486
by: Paul | last post by:
Hi I have 2 data grids and several controls on a web page. The grids will vary in size, just wondering if the lower grid could be covered by part of the upper grid depending on its size or is there a way to dynamically shift the lower grid so it appears just below the upper grid? Thanks. -- Paul G Software engineer.
2
10781
by: dilip.movva | last post by:
Hi, In the ItemDataBound of my datagrid I am creating a checkbox dynamically. I have the eventhandler defined for CheckedChanged of the check box. The event is not firing. The grid is bound in the Page_Prerender method. My code is something like this Private Sub grdMissingData_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdMissingData.ItemDataBound If e.Item.ItemType =...
0
2073
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab, System and Software Engineering Lab), ULB (deComp) and the Belgian Association for Dynamic Languages (BADL) are very pleased to invite you to a whole day of presentations about the programming languages Self, Smalltalk and Common Lisp by experts in...
3
1573
by: sqlboy2000 | last post by:
Hi, I've just started playing around with master / detail pages and I'm trying to simply change the detail page displayed in the contentplaceholder control from code behind. I can't seem to find any examples of this. Does anyone know how to do this? Thanks in advance.
1
923
by: Hugo Flores | last post by:
I'm dynamically creating a user control based on what the user selected from a dropdownlist. The problem I have is that since I want to use the contols' viewstate inside my user control, I need to create the user control in the Init of the page that has the dropdownlist. But in the Init event, I don't have the value of the dropdownlist selected value. So my question is, how can I make this work? Thanks
13
17168
by: salad | last post by:
Operating in A97. I didn't receive much of a response conserning Pivot tables in Access. Pivot tables are nice, but a CrossTab will work for me too. Using a Pivot table, one is actually launching Excel for data viewing. I'd prefer the user stay in Access. Creating dynamic crosstab queries is pretty simple. The problem is that the column count may shrink or grow depending on the filter.
0
1064
by: nareshkumarhk | last post by:
hai all, i would like to have a help here. How to drag and drop data from contols in atlas. the senario is: i want to drag and drop the containing values in the listbox1 to listbox2 how to do...
1
1677
by: BillE | last post by:
vb.net, visual studio 2005, windows forms My application dynamically creates controls and adds them to a panel on a form. This is done in the form load event. I don't know if I would call it flickering, but parts of some controls get displayed before others. They don't exactly flicker, they just appear in pieces, instead of all at once. The controls include nested panels. I have tried to avoid TableLayoutPanels because the...
5
2586
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization algorithm to solve a certain messy problem, and many different things. For that I often use several general modules that I have written, like implementation of certain data structures, and small general "utility" functions/classes, plus of course...
0
9655
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
9498
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
10363
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...
0
10172
jinu1996
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...
0
9964
tracyyun
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...
0
6749
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();...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
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...

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.