Click here to Skip to main content
15,886,708 members
Everything / User Controls

User Controls

user-controls

Great Reads

by Christoph Buenger
Describes PHP application development with the free Scavix Web Development Framework (Scavix-WDF).
by Avelino Ferreira
The easiest way to implement the ToolStripControlHost and ToolStripDropDown classes, in a UserControl, in order to display a Container/Control beyond the limits of its Parent Container and Parent Form, with very few lines of code. Let's uncomplicate ...
by MarkLTX
A subclass of the WPF TextBox control that displays an ellipsis when the text doesn't fit.
by freedeveloper
A small control to control paging in Windows Presentation Foundation.

Latest Articles

by Michael Haephrati
How can a Static Library embed resources and other data so any application (even a Console based one) can use them.
by Adam Zgagacz
Simple WinForms auto-repeat button in a few lines
by WyoMetz
Simple and easy paging of a WPF DataGrid with DataTable and LINQ queries
by Stas Wolski
This article describes how to implement a meeting room booking system in an ASP.NET MVC project with dhtmlxScheduler.

All Articles

Sort by Score

User Controls 

31 Oct 2014 by Christoph Buenger
Describes PHP application development with the free Scavix Web Development Framework (Scavix-WDF).
3 Aug 2016 by Avelino Ferreira
The easiest way to implement the ToolStripControlHost and ToolStripDropDown classes, in a UserControl, in order to display a Container/Control beyond the limits of its Parent Container and Parent Form, with very few lines of code. Let's uncomplicate ...
13 Jan 2012 by MarkLTX
A subclass of the WPF TextBox control that displays an ellipsis when the text doesn't fit.
27 Jun 2012 by freedeveloper
A small control to control paging in Windows Presentation Foundation.
16 Dec 2011 by Henryk Filipowicz
A web user control for selecting a file from the file system.
30 Mar 2015 by SSDiver2112
Interactive Design Time Control Overlays to make editing custom controls easier.
24 Jun 2015 by Nadun Liyanage
This tip describes creating a user control to display a drop down calculator that pops out like the DateTimePicker in Visual Studio
10 Nov 2017 by knockNrod
Creating Embedded Controls for WonderWare InTouch and WinCC
23 May 2012 by VJ Reddy
For the properties of the object set at design to be persisted in the form the DesignerSerializationVisibilityAttribute with the argument DesignerSerializationVisibility.Content is to be used like _Public ReadOnly...
3 Sep 2012 by John Atten
Examination of a quick way to create more useful expandable groups in the .NET ListView control.
5 May 2014 by Gerald Gomes
This article will make an attempt to describe a basic way to start implementing animation in WPF.
22 Oct 2012 by User 9125307
I think this would be the perfect solution for you:private void ButtonName_MouseHover(object sender, EventArgs e) { System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip(); ToolTip1.SetToolTip(this.button1, this.button1.Text); ...
17 Aug 2013 by adriancs
An Office 2010 Style Color Picker for .NET WinForm.
13 Apr 2011 by Sergey Alexandrovich Kryukov
This is not a problem. You can even host and plug-in whole WPF applications. I think you don't need this, so I'll explain a skeleton of plug-in design.Let's assume you have host application which never changes (more exactly, its plug-in support sub-system is not changed or is changed...
24 Jan 2012 by Shahin Khorshidnia
Hello,I did almost a same thing but by WPF for a company.I made some Icons that they where connected together with lines. (Like VISIO)I've never seen any prepared user control for connector point. At leat I don't know.I built it and I think you have to build.1. Save dimensions...
25 Jan 2012 by Sergey Alexandrovich Kryukov
My advice is: don't do it this way. This is possible in principle; I knew few attempts, all pretty much unsuccessful; and it's clear why.I explained what to do in my past solution: Drawing Lines between mdi child forms[^].The question is not exactly the same as yours, but the right...
25 Jan 2012 by Espen Harlinn
I think you are looking for something like this:WPF Diagram Designer - Part 1[^]WPF Diagram Designer - Part 2[^]WPF Diagram Designer - Part 3[^]WPF Diagram Designer - Part 4[^]The articles are well written and the concepts fundamental to WPF designer integration, but if you are new...
25 Jan 2012 by Sergey Alexandrovich Kryukov
Now, lets turn to WPF and let me give you some further ideas before we close this discussion and you continue on your own. I hope you will choose to accept this one formally, too. (You can click green "Accept" button on more than one.)With WPF, you can put all your diagram elements on the...
13 Aug 2013 by Volynsky Alex
Let's try to read the Framework-Based Software Development in C++[^] book.This book provides a detailed methodology for implementing frameworks -- today's most important advance in object technology to solve real business problems. This book introduces a new methodology for building frameworks...
15 May 2011 by #realJSOP
For winforms login:User Login For WinForm Applications[^]For Opening another form after logging in:Multiple Subsequent "Main" Forms in C# Apps[^]
14 Jul 2011 by Sergey Alexandrovich Kryukov
You don't need to add any thread-safe features in the custom controls. Anyway, a non-UI thread cannot call any UI methods or properties. Working with UI from the non-UI thread is nevertheless possible, but the calls are dispatched to the UI thread using inter-thread invocation...
2 Jan 2012 by Shahin Khorshidnia
Hello,Use delegate in your User ControlFor example you got a button named "Add" on your control:public partial class Test : UserControl{ public Test() { InitializeComponent(); } public delegate void RunMethodHandler(object sender); public event...
12 Oct 2012 by Sergey Alexandrovich Kryukov
Did you try to find anything at all. You will find plenty of samples:http://bit.ly/Q6JA1m[^].Perhaps this is not what you really want.Your question in not completely incorrect, but can be greatly improved. You should have re-formulated it:"How to use Wikipedia, Google, CodeProject...
12 Oct 2012 by Kenneth Haugland
There is one guy that has made some pretty fancy 3D WPF animation of raindrops in water.His blog, were the code is explained:http://stuff.seans.com/2008/08/24/raindrop-animation-in-wpf/[^]And you could download the source code in C# here:http://wavesim.codeplex.com/[^]
1 Nov 2012 by fjdiewornncalwe
You need to do a couple things.1) Create a local variable holding an instance of the subform in the parent forms class. var MyFormObj;2) In your button click handler you create an instance of the form if it doesn't already exist and show it. If the form already exists then you just...
12 May 2019 by Jeff Gaines
OK, solved! Firstly the User Control must have its own ImageList property so I added that with a 'get' accessor only. Then the property became: [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Browsable(true), Description("The Image Index for the button"),...
13 Nov 2010 by jarvisa
public void ControlStatus(Control control, bool isDisable){ foreach (Control c in control.Controls) if (c.HasControls()) ControlStatus(c, isDisable); else { WebControl wc = c as WebControl; if (wc != null) ...
27 Nov 2010 by 69Icaro
After you've added the reference, you can call the UserControl directly from the code behind, like this:public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.Content = new...
10 Feb 2011 by #realJSOP
They handle the various drag events:DragEnterDragLeaveDragDropDragOverItemDragGiveFeedbackYou can handle those events on any control you want. Here's a decent...
26 Feb 2011 by Henry Minute
To achieve your aims you will probably have to write a UITypeEditor[^] and one or more ControlDesigners or one of its descendants and quite possibly one or more TypeConverters. From your description possibly an ExpandableObjectConverter[^].Here is a link to an example that uses most of these.[^]
13 Mar 2011 by VENKATHEGDE
Hello Everybody,I have an interesting problem at hand.I have a need to create a WPF Application which will host several UserControls. (The application does just that - serves as a container with docking abilities for UserControls)The application will also host the data model for the...
13 Mar 2011 by Sergey Alexandrovich Kryukov
Answering follow-up Questions:Question 1Consider the following sample://plugin-code of the implemented plug-in interface:Control[] IControlPlugin.AddControls(DockPanel parent) { Button leftRect = new Button(); leftRect.Content = "_Left"; DockPanel.SetDock(leftRect,...
3 May 2011 by yesotaso
Google[^]1st LinkCreating Custom Controls-Providing Design Time Support 1[^]2nd LinkCustom Properties and Custom property Editor[^]
18 May 2011 by OriginalGriff
Save it in the Session; set it in the page load.How to do it will differ slightly depending on your web site coding method, but Google for "using Session variable" with your chosen language should find it ok.
20 Jun 2011 by Pete O'Hanlon
Rather than attempting to do this in a Win Forms manner, you can achieve this in a WPF-centric way by adding an IsSelected property to the class behind the list. Then you bind to this property using the following: ...
20 Jun 2011 by derinpdavis
I think Popup will be the best option for you. You can make a popup control and show on top of your main control.Popup.IsOpen - property will work as Window.Show() - function public static void Show(UIElement parent, string message){ Popup popupWindow = new Popup(); ...
13 Jul 2011 by Shameel
The namespace of the resource is the project's namespace + the directory structure of the resource file ('\' replace with a '.').If 'myicon.ico' is in 'images\icons' folder in your project and the project's default namespace (in Project properties) is 'shahzad', then your icon's full...
5 Aug 2011 by Shameel
You can expose your constituent control properties as properties of the user control, like this:public string Text1 { get { return textBox1.Text; } set { textBox1.Text = value; }}Similarly, you can expose events the textbox as event of the...
12 Feb 2012 by CRDave1988
http://forums.asp.net/t/544737.aspx/1[^]
12 Feb 2012 by Sergey Alexandrovich Kryukov
[Something is going wrong on the server: I deleted my answer because it looked like it was posted twice, after refresh the page I found it was posted only once and deleted; when I post again all my new posts appear to be deleted.]Did you try to run it under Debugger? You would find out the...
13 May 2012 by Rahul Rajat Singh
So What i understood is that you need your user control to have the attributes that you can set from aspx markup.If you define public properties in your user control then use can use it like attributes from you pages' asp.net markup. Tell me If my understanding is not correct.
27 Jul 2012 by Kudredin
Making use of the User Defined Fields to help better organize emails, and keep track of informaiton
5 Sep 2012 by Sangramsingh Pawar
in your web user control class define eventpublic event EventHandler SelectionChanged_UserControl;//use OnSelectionChanged event of dropDownList void Selection_Change(Object sender, EventArgs e) { SelectionChanged_UserControl(sender,e); }//you will get...
5 Sep 2012 by Rickin Kane
its a simple solution First in user control create a delegate above Page_Load() method public delegate void OnSelectedIndexchanged();public event OnSelectedindexchanged Setactionname;then in your dropdown selected index change add following line if (Setactionname!= null) ...
10 Sep 2012 by Dinesh Ambaliya
I have a web user control which contains 'AssociatedLableId' property and a label.and added a Label and a button in aspx page and registered User Control .Now when I click the button then the text of label control of aspx page...
14 Oct 2012 by Curtdawg123
You can use thispublic void main(){ pictureBox.Click += new EventHandler(pictureBox_Click);}public void pictureBox_Click(object obj, EventArgs ea){ // This get executed if the pictureBox gets clicked}
13 Dec 2012 by Sheikh Muhammad Haris
Save your string "key" value in a publicly declared variable in your server side event, then access it in your aspx code.public string myKey = string.Empty;then in your aspx code]]>test link
19 Dec 2012 by Adam R Harris
You are going to have to create a delegate to add the controls for you, something like this:** assuming your flow control is called 'flow' private delegate sub delAddControl(ctrl as Control) private sub AddControl(ctrl as Control) if (flow.InvokeRequired) then ...
6 Feb 2013 by BotCar
Skeleton of your XAML: In your code-behind:for(int i = 0; i
3 May 2013 by TnTinMn
Quote:DougsSoftware - 2 hrs agoHi, I created a class named UserControl2 that Implements ICustomTypeDescriptor, and I made a simple GetProperties Function (below). It works except the (Name) property does not appear in the property grid. Do you know why (Name) is not there? I would like an...
23 May 2013 by RelicV
Alternative for AutoComplete control without Ajax and Webservices
4 Jul 2013 by bhuvamehul
To do this you have to take third window form which size is same as Parent form and that form's FormBorderStyle set to none,set background color as you want and set opacity to 30%. Show this form when child form activated, keep child form always on top. Hide this new form when child form closed.
14 Oct 2013 by Jamesking56
Adding functionality to the iDevUI framework
29 Nov 2013 by BillWoodruff
I've gone back over your original question and realized I didn't understand what your goal is here. Here's a working template you can use to experiment with ... hopefully learn from.The challenge, in this case, is interesting: you are kind of "bending" the RadioButton to a task it wasn't...
6 May 2014 by Daniel Lieberwirth (BrainInBlack)
This describes a simple way to create interactive, bitmap based, buttons for WinForm applications.
14 May 2014 by atlaste
How to fix hiding controls in the Visual Studio user control designer
29 Dec 2014 by Agent__007
Adding this answer as per the OP's response to my comment above:Did you try Pack URIs[^]?Basically, try either:pack://application:,,,/Images/icon_HMI_NewDeci.pngor/{YourProjectNameHere};component/Images/icon_HMI_NewDeci.pngThat should do the trick.
4 Apr 2016 by Gokulprasad05
public partial class StopWatchDemo : Window{ DispatcherTimer dt = new DispatcherTimer(); Stopwatch stopWatch = new Stopwatch(); string currentTime = string.Empty; public StopWatchDemo() { InitializeComponent(); dt.Tick += new EventHandler(dt_Tick);...
9 Sep 2020 by Rick York
I don't have a specific solution but you are on the right track. Ages ago, I made a derived FileOpenDialog class or what ever MFC calls its version and made a custom dialog that included a bitmap preview. That has since been render obsolete but...
26 Mar 2023 by Graeme_Grant
If you want to pass the event from the UserControl to a parent container, like a Form, then you need to: 1. expose either a Method to a delegate (a method or function to call from within the UserControl) or 2. add a public Event property to the...
7 Apr 2010 by elad2109
Hey everyone,I have 2 questions, maybe you could help me out.1. I built a DLL from the following code:using System;using System.Collections.Generic;using System.DirectoryServices;using System.Linq;using System.Text;namespace AutoAD{ public class Class1 ...
6 Jun 2010 by Henry Minute
OK! Problem resolved. Not solved, you'll note, as I'm not sure why your code was misbehaving. However, if you make these changes it works as desired.First your btnAddPump_Click method. At the end you Update all existing pumps, rather than just setting the fuel for the new one. This will slow...
5 Jun 2010 by Henry Minute
I have just sat down for an infusion of stimulants after my previous post and as I did so the answer came to me. So my coffee is getting cold while I type this.In your PetrolPump when you set the FuelList I believe you set the DataSource for your ComboBox to the new FuelList. Since all the...
15 Jul 2010 by Sandeep Mewara
If it is ASP.NET, then look at this article:Customizable 'Loading' Control for Web Applications with Designer Support[^]UPDATE 1:Well, If it's Winforms, have a look at this control:Progress-O-Doom[^]A Pretty Good Splash Screen in C#[^]A .NET Progress Dialog[^]
28 Sep 2010 by Member 7454184
I am working on a user control named DateMonthControl. It is supposed to show months between a min-date and a max-date - and to enable the user to select a specific month.That is: Minimum month may be september 2011 and maximum month may be april 2014. The user must then be able to select a...
13 Nov 2010 by PSU Steve
You can just use "not IsDisable" versus the IF...ELSE block. Additionally, the recursive call to ControlStatus should be done all the time so that the parent control is enabled/disabled along with the children. // to enable\disable the control & its child controls public...
2 Nov 2010 by santoshamrutha
try to register the script instead of attributes.add ,can you see error on your page status example page.registerscriptblock("","","","");since you are using ajax script manager the javascript is not being handled so if you register the script it should run .
2 Nov 2010 by Bryian Tan
hi,The JavaScript will get call if you click on the button twice. If you debug it, you will notice that the fvATSDetails_ItemCommand method will not be executed on page load. The only time the method get trigger is when you click on the button. If you want the to add the JavaScript to the...
23 Nov 2010 by Versile
Add an InstallerClass to your main project, then Custom Actions of your Setup file will call it. On the properties of the InstallerClass you can execute AfterInstall, BeforeInstall, etc. You can pop up a form here (though this is bad form and SEPERATE from your installation, i.e. very difficult...
29 Jan 2011 by Steve Wellens
1> All images come on new line i want them next to each other.Do you mean the user controls? Images by default display inline. You maybe able to change the way the usercontrol displays by setting it's style: style="display:inline" 2> How to detect which radio button is clicked as i...
26 Feb 2011 by Sergey Alexandrovich Kryukov
This is quite possible but not easy at all; you'll to write several things to allow custom edit in the PropertyGrid. I think modal form is not a good idea as you can do much better by providing a custom in-place editor. However, a modal form is also possible: you in-line editor will be the...
15 Mar 2011 by Venkatesh Mookkan
The WPF Designer in Visual Studio is a basic designer. But the Visual Studio 2010 has better WPF Designer. The rendering of Design Time depends on the Controls and Complex design used in that particular Window or UserControl.For example:If you have a control which load records from DB on...
7 Apr 2011 by Ramu Sangabathula Original
not sure what exactly your problem, I have used your code and dynamically able to load the user control from page load event and when i click the save button it is perfectly firing the event. but if you want to load the control and fire the button event simultaneously, then you need to...
7 Apr 2011 by r verma
Correct me if I didn't get your issue correctly!In your code it seems like you are adding dynamically a UserControl on Click_Event of a Button in your aspx page but problem is once your Change Password UserControl will be dynamically loaded and when you will try to click its Button (inside...
22 May 2011 by Christian Graus
That's precisely what you asked for. Put it in a container, and it will be inside that container. You need to resize your container to fit, or, put it somewhere else. I don't see what other options you expect to have. If you want your container to resize itself to fit your list, you need to...
20 Jun 2011 by Manish V Mahajan
Hi,I'm new to WPF and C#. I've tried to seach the web for a simple tutorial or code on how I can capture the list of all the selected items in a listbox.I am doing the following:1. Have a List where A has two properties: Name and Address.2. I am using DataBinding to populate...
23 Jun 2011 by Manish V Mahajan
Was to find a solution posted on MSDN ( href="http://social.msdn.microsoft.com/Forums/en/wpf/thread/7fd1df22-03b9-408b-80a4-e0a642a3a857">).Basically I did the following:1. Add a MouseDoubleClick in my main DataGrid (this works even though you have DataGridTextColumn or...
14 Jul 2011 by BobJanova
I recommend that you don't create one control per file. That seems unnecessary, the list can manage all the entries and painting itself, which will save you a lot of window handles and time/memory used in creating controls. You should not need to do the display in a separate thread, it should...
26 Jul 2011 by AndrewR73
@mahabubur rahman:My apologies, your suggestion was spot on. It turned out that the using() statement was **exactly** the problem. I was able to solve the problem by changing the code to the following:protected void ddlColor_SelectedIndexChanged(object sender, EventArgs e){ ...
2 Aug 2011 by Sergey Alexandrovich Kryukov
Just create 5 events; raise each event where your placeholders are. For example.public event System.EventHandler StartingInitialization;public event System.EventHandler StartedInitialization;//..protected override void BeginInit() { if (StartingInitialization != null)...
31 Aug 2011 by Reiss
You could add an accessor property to your LabelHolder control to do it for you.public class LabelHolder{.... public string Text { get { return lbCan.Text; } set { lbCan.Text = value; } }}so your code becomespublic partial...
31 Aug 2011 by Hasan.Hof
Create a Property in the user control: public string Name { set { lbCan.Text = value; } get { return lbCan.Text; } }In the the Default.aspx page just assign a value to that property. ucTest.Name = "hasan";
2 Sep 2011 by Rupesh Kumar Tiwari
If I understood correctly:Why you need some attribute like required. As suggested you can use .Net inbuild requiredfield validator or You can also make validation on your server side setter of your property. If you find invalid then throw exception or show some message.If I understood...
20 Oct 2011 by czeshirecat
I think I've done it. I'm reporting my solution in case anybody else is struggling [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]public DataGridView View{ get { return dgv; }}The above exposes the DataGridView in the property browser, and persists the...
17 Dec 2011 by OriginalGriff
Yes - don't use a text box.Have a look at this: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/Calendar/Calendar.aspx[^]
3 Jan 2012 by csprogrammer
Thank you your answers were really helpful :D
15 Jan 2012 by janwel
Hello programmers, got a few twitching i need to resolve here. I am creating an excel like updating wherein if the user click on a specific column/row it will change to textbox and when he click it another it will return to label but it is already been updated. By the way I am using...
19 Jan 2012 by amolpatil2243
hi,you can write the rowdatabound event of gridview and then get that control using type casting,get controls value then whatever you can bind to this and reassign to the controlrefer solution1 syntax
19 Jan 2012 by prot0col
You can do something like this on RowDataBound event of the gridviewI am writing an example for textbox if (e.Row.RowIndex != -1){ if (e.Row.RowType == DataControlRowType.DataRow) { TextBox txtCourseCatID = new TextBox; txtCourseCatID = ...
12 Feb 2012 by Nigam Patel
HI Friend,you can create a eventhandler in your user control. and use use that event into your parent control.So when you click on you button that will fire the parent page event.For Example:on my aspx page code:
20 Feb 2012 by drkterror
Hello fellow developer, the catch is I am developing a page wherein there is a nested user control inside my gridview(grdCategory). So Ive manage to bind it programically(woking no doubt) using Sub that I could call anytime. Using Parent-child(usercontrol) hierarchy, the user control which has...
20 Feb 2012 by sarah.cs
Hello Everyone,I've created a VB.NET application and made a WPF user control (Text Box) . Now i want to read data from text file into this text box . I can read data into win text boxes but unable to read it into WPF text box. How can i do this?
20 Feb 2012 by Erik Rude
You have to get the concept of Binding clear in your mind. Once you've got that it is no problem. Have a look at some of the very simple WPF examples on this site. I'll get back with a couple of helpful link in a minute.WPF Data Binding - Part 1[^]OrMoving Toward WPF Data Binding One...
25 Feb 2012 by Dave Kreskowiak
Two things.It's a REALLY bad idea to call your control UserControl as that is already used as a class name in the .NET Framework. Your control should be called something a bit more descriptive.You forgot to add the newly created contorl instance to the Controls collection of its parent...
1 Mar 2012 by Sunasara Imdadhusen
Hi All,Now i resolved issue using following code. I have replaced following linetxtTextBox.SetBinding(TextBox.VisibilityProperty, new Binding("Redactable") { Source = this, Converter = new BoolToVisibilityConverterReverse() });with this.MapBinding(RestrictedControl.ValueProperty,...
13 Mar 2012 by Sander Rossel
Recently I have been developing some WinForms Controls for my company. Sometimes I inherit an already existing control and sometimes it's a composite control with different other controls on it. However, I have a problem, or rather a question.Now my problem lies in how to properly encapsulate...
16 Mar 2012 by Sergey Alexandrovich Kryukov
OK, let's start from some example, but first of all, I want to have the techniques of delegation or events to a host control which would work not only with Forms, but also with WPF, and, more generally, in all cases where you have composed event-enabled members which should remain private. I...
26 Mar 2012 by André Kraak
You will have a better chance off getting a response if you ask this question at the article: Dynamically add and remove user controls[^] you are referring to.Just use the "Add a Comment or Question" button at the bottom of the article.