Click here to Skip to main content
15,892,927 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 Title

User Controls 

24 Nov 2011 by ortund
Login system with breach redundancy handling.
18 Oct 2010 by Gagey1971
A simple .NET control to display the 'standard' 13x13 grid for two card poker hands.
15 Jun 2011 by isaks
Shows how to create a nice looking photo frame control in WPF and animate it using the Ken Burns effect
21 Oct 2010 by Ed Guzman
The Chart control gives you freedom to develop graphic reports.
10 Jun 2012 by OriginalGriff
A Generic Abstract class providing a true Pop-up control, implemented in a multiple selection drop down list.
1 Nov 2010 by Sacha Barber
A control that partially emulates a popular phone.
4 Apr 2013 by Michael Mann (mann.DEV)
Plugin migration with new features of .NET 3.5.
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...
13 Mar 2012 by Sergey Alexandrovich Kryukov
I think the way of exposing an event of a ControlChild to the interface of ControlHost you have described as "a lot of work" is the most appropriate.Perhaps you can do a little better using the following technique: you can create some interfaces representing each of the nested controls and...
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 Jun 2011 by jeanlibera
How to create a vertical or horizontal scrolling area with scroll buttons and a hidden ScrollBar.
25 Jul 2014 by JamesHurst
Walks through the creation of an on-screen virtual keyboard for entering non-ASCII chars
10 Jun 2014 by Sen Jacob
A simple task scheduler utility by which you can schedule a task to run at any time or interval
11 Jun 2014 by Sen Jacob
This is an alternative for "A Task Scheduler Library for .NET Applications"
7 Oct 2012 by Andriks
A MessageBox replacement with some much needed extras
13 Jun 2014 by Neha Mukesh
i am creating a user control in which i have four image buttons like export to excel,pdf,word,print document.I want to export gridview that is in my base page from where i am accessing this usercontrol now my problem is that how to send id of that gridview and what function i should write to get...
13 Jun 2014 by goathik
you have two options.first, you initialize the grid id as a property on your page_load. just create a public property with get;set; on you user control and set the grid to it and then you will have it.second way is to handle the control's click buttons on the page that uses the control....
12 Sep 2020 by Member 14922487
I have user control called UCPlayerAccount in where I have created "model", an instance of class PersonModel, and populated it with values. Now, in UCPlayerAccount i have button that loads another user control, let's say it is called UCX, with...
12 Sep 2020 by OriginalGriff
You have "encapsulated" your Person model, so either provide a property to return it from your UserControl, or write a method which returns a specific instance.
12 Sep 2020 by BillWoodruff
To the extent your goal is not, imho, fully revealed, I am going to show some code that reflects some arbitrary decisions ... in the hope you;ll find the strategy and methods useful :) I suggest you use a kind of model-view design: using...
25 Oct 2013 by Ali_100
How to access parent page label's text in user control but from javascript of user control?
11 Feb 2020 by .Net Perfect Dev
hi, i create a project WPF with 3 files xaml of user control in this architecture my question is how can i access from User control 1.1 to the the Grid control Parent? my objectif is maximize the popup child1.1 in same height and width of Grid...
11 Feb 2020 by AnkushK1
Try this Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GridControl}},Path=ActualWidth}"
12 May 2019 by Jeff Gaines
I have written a very simple user control in C#. It looks like a ComboBox and when you click the drop down it fires up either an OpenFileDialog or FolderBrowserDialog. When the user selects a file or folder its path is shown in the text portion of my control. The control just has a button docked...
12 May 2019 by Jeff Gaines
Thanks Gerry. I realised as soon as I pressed the button I had missed some important information :-( I have a base control, looks like a ComboBox and of course I can access all the properties in that. The Button it contains has an associated ImageList. I then have a File/Folder picker derived...
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"),...
17 Jan 2013 by arsr24
I have a usercontrol called AddRow and a form called TimeSheet ,Timesheet has a save_btn event, on click of save_btn the value enter in usercontrol should be written to database,but I am not able to access the value from usercontrolbelow is the codepublic void save_btn_Click(object...
17 Jan 2013 by OriginalGriff
You don't want to create an new instance - you need to get the actual instance of the UserControl that you created dynamically and presented to the user for him to fill in. There are two ways: 1) Keep a class level reference in your form class when you call new AddRow() to add the control,2)...
14 Nov 2012 by Divya RS
This is my ascx code: function fnMsg() { var value = document.getElementById('txt').value }
14 Nov 2012 by Manfred Rudolf Bihy
The ID attribute of a HTML tag that is modified with the runat="Server" attribute changes. This ID is only available on the server side now and to get the ID of that tag as it is rendered in the HTML sent to the browser you'll have to user See here:
14 Nov 2012 by n.podbielski
If you are using asp.net 4 you can use Instead of your server side html tag.Or obtain client id of this tag in aspx/ascx var id="";
26 Feb 2011 by MRAKAR
Hi,i'm making my own user control and have 2 questions1. i want to add a button on default properties list and i want to open a modal form when that button is clicked,2. i want to group my control properties in one category (the attribute Category(...) doesn't work, as i found it works...
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...
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.[^]
27 Feb 2011 by MRAKAR
I thought something about thispublic Sometype PropertyName{ get { return SomeValue; } set { (new Form()).ShowDialog(); }}
23 Nov 2009 by Member 4291902
How to add controls to a user control in WpF in the design view?
24 Nov 2009 by Christian Graus
You drag them on.  Please post once with all the tags, not over and over.
20 Nov 2013 by Manikandan Sekar
I am developing an application using WPF with C#.I am showing a User Control as a Context Menu.The User Control displays a list of Buttons from DataGrid,now what i need is to show a Context Menu for the Button while the previous ContextMenu(i.e. User Control) should be open.The...
12 Oct 2012 by user_code
Hello,I develop a c# user control.In that control, I have a button. When the user clicks the button at runtime, a new control (for example, pictureBox) is created ,next to the previous pictureBox.How can I do it? especially when I don't know how many pictureBoxes the user is going to...
12 Oct 2012 by OriginalGriff
Try:PictureBox pb = new PictureBox();pb.Location = new Point(oldPb.X, oldPb.Y + 100);pb.Size = oldPb.Size;Controls.Add(pb);
14 Oct 2012 by user_code
Hello,1)I develop a c# user control.In that control, I have a button. When the user clicks the button at runtime, a new control (for example, pictureBox) is created ,next to the previous pictureBox.I did it that way:PictureBox pb = new PictureBox();pb.Location = new...
14 Oct 2012 by OriginalGriff
Add a List to you UserControl:private List Pictures = new List();Then when you add it to the controls list, you also add it to the Pictures:PictureBox pb = new PictureBox();pb.Location = new Point(oldPb.X, oldPb.Y + 100);pb.Size =...
13 May 2012 by Andy Lanng
Hi,I am creating a website where I would like some neat context menu controls. I have already found some handy code to create the menu (but post 'em if you've got 'em) but I'm looking to create a standard UC for the site. I was hoping to be able to add items to the control in the same way...
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.
15 May 2012 by Greysontyrus
You need to add the following to your enclosing class: [ParseChildren(false)] [PersistChildren(true)] public partial class ContextMenu : UserControl {...}That will allow you to add items between the opening and closing tags of your UserControl. I have also included...
13 Aug 2019 by pieterjann
Hi,I have a user control and i need to edit some things on the event similar to "Shown" with forms.I tried the following but that does not work:Added the following line to the designer:this.Shown += this.HandleControlShownand added this to the class of the control:...
6 Nov 2012 by Sanjay K. Gupta
Eevent declaration code, may be helpful to you.//declare a delegatepublic delegate ShownEventHandler(string args);public event ShownEventHandler Shown;private void HandleControlShown(object sender, EventArgs e){ if(this.Shown!=null) { this.Shown(String.Empty/*your...
13 Aug 2019 by Jens Madsen, Højby
OK, this is old, but as I often face issues concerning 'stuff' that needs a visible window/window handle, I use a System.Windows.Forms.Timer like this: (This UserControl hosts a native NamespaceTreeControl that needs a visible handle to initialize) Private Sub...
18 Mar 2014 by Emmanuel Cerna
Hi, i hope some of you can help me with my problemIm trying to do an app in C# and visual studio.I want to add a new user in my Active Directory with this fields (taking the propieties from txtboxes and 1 passwordbox):NAME (txtname)LAST NAME (txtlastname)WINDOWS LOGIN...
18 Mar 2014 by Kornfeld Eliyahu Peter
Start reading here: Howto: (Almost) Everything In Active Directory via C#[^]
20 Sep 2016 by JordanTrajkov
I make one asp.net web forms app, I create user control, in this user control I insert few standard .net controls. Now in my page.aspx I want dynamicly to insert this user control. I put a button, something like "Add new control". If I click on it I'm adding a new control to the page. And all...
2 Nov 2010 by sujanir
Hi,Iam trying to open a new window when a button present inside a formview on my web user control is clicked. I have this code in my ascx page. function OpenFiles() { alert('open files'); ...
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 aidin Tajadod
Hi, It might be because of error.you are doing :btnDoc.Attributes.Add("onclick", "javascript:openFiles();");but the name of your function is OpenFiles !! so change your code to btnDoc.Attributes.Add("onclick", "javascript:OpenFiles();");(upper case o)hope this can help.
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...
3 Nov 2010 by TCVinodh
Pls write the Javascript Function on the continer page of the ascx,thts means aspx page....(the back page of ascx)then run it will fire.......
6 May 2013 by abbijohn
Hi,I have one webpart in sharepoint 2010,have to add one more usercontrol(.ascx) in that webpart with configurable property.Is it possible..This one is working fine in normal webpage(.aspx),but it is not working in Sharepoint ,it shows error like 'filename.ascx is not allowed in this...
7 May 2013 by sandeepkumarvemula
do u have another user control in layout folder.bcs usercontrols r stored in layout folder.
19 Dec 2012 by Kieran Crown
Okay, I want to add multiple user controls into a flow panel at one time without the UI freezing, I've tried adding the controls from a Background Worker but get an error about how it cannot be added because it can't change parent control or something like that, any help would be appreciated.
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 ...
3 Aug 2016 by Mr.TMG
Hi, I have a user control that is designed to display Names. Inside the control there is a label that should always remain centered and can have an unknown length of text.Are there any clever methods out there for adjusting the font size of the label such that it fills the user control as...
26 Aug 2013 by Sergey Alexandrovich Kryukov
Please see my comment to the question. Even if you implement the behavior you want (which is itself surprisingly difficult, because of font hinting), you may run into a very unpleasant stylistic clash with other elements of your UI.Rather, you should review your UI design.—SA
26 Aug 2013 by Dave Kreskowiak
So you want the font to resize itself to fit the string in a label?? The method doesn't exist. You'll have to code this up yourself.I did this (a long time ago!) by creating my own control, inherited from Panel, not Label, and drawing the text myself.You'll need to use MeasureString[^]...
3 Aug 2016 by Stephen Soper
I got this working without using a panel, just a label. I call this code when the text changes or the size of the label changes (I have it set to anchor on all sides). In my case, the text is simply a number that changes every second for near real time visual updates. I hope this helps the...
2 Dec 2013 by PBGuy
Hello all,I have to develop/create a usercontrol(content connector) to map client's digital assets to adobe DAM(DIGITAL ASSET MANAGEMENT) servers for file related operations like moving files from client location to adobe DAM's and related.How can I achieve this..?What sort of...
2 Dec 2013 by BillWoodruff
There is an Adobe Forum here on CodeProject, but it gets very little traffic: [^].I'd recommend you post your question on one of Adobe's tech forums. Here's the result of a search on the Adobe tech forums for "Digital Asset Management:" [^].Search Adobe tech forums on "CQ Connector:" [^].
30 Mar 2015 by SSDiver2112
Interactive Design Time Control Overlays to make editing custom controls easier.
29 Oct 2012 by Mihaly Sogorka
AutoComplete control for web-develepoment written in pure JavaScript
28 May 2013 by Giorgio Minardi
How to create an MVC HTML Helper and package it for Nuget.
23 May 2013 by RelicV
Alternative for AutoComplete control without Ajax and Webservices
6 Jan 2011 by madihanasim
Is there any other alternative of usercontrol other than webpart and iframe?I would like to use this in my asp.net application.
6 Jan 2011 by Espen Harlinn
You can derive custom controls from System.Web.UI.Control and it's descendantsOften more efficient - but sometimes way more work. It depends on what you are doing.RegardsEspen Harlinn
17 May 2012 by Jim Parsells
Explorer TreeView control with Shell Folder access class and Icon management.
11 Nov 2012 by JerryBNewhouseJr
Create a simple, flexible, standalone ProgressBar that can be added to any class with relative ease.
8 Jul 2010 by piyushpiyush
Hi...I have implemented Anders:ImageCropper control. it's working fine with my local system but on my live site image is not display with this control.How to solve this issue?my code is below..aspx page
8 Jul 2010 by Johnny J.
The best way to get help is probably to contact Anders, the author of the control.Because it is not a standard control, there might not be that many people here who have experience with it... (Then again: With +7M users, there ought to be at least a few...)
16 Oct 2012 by Igor Kushnarev
How 3D carousel could be implemented for Android platform
1 Apr 2011 by xandytsui
An Introduction to a new Android-java based MVVM Presentation Framework
12 Jul 2013 by Unnikrishnan_S_N
Draw pattern instead of password for login screen.
16 Mar 2012 by PravinSingh
Is there any tool to check if UI controls on a desktop app or a web app are properly aligned, the distance between them is consistent and the controls are following UI standards?Because if there isn't any already, I am planning to write one. :)
16 Mar 2012 by Sergey Alexandrovich Kryukov
I don't know if such tool is available. I would not be surprised if there are no such tool, and I know why: it would be useless. I can guess where it comes from: you probably develop UI manually, it means by some sort of graphical designer, and you use absolute positioning. In other words, you...
14 Jan 2011 by dingelen
Hi,can someone tell me how to reduce/eliminate the flickering and speed up redraw in this project.http://dl.dropbox.com/u/18687229/Versions.7z[^]I've been fiddling with: userpaintdoublebuffersuspendlayoutbegin resize / end resizeThe custom controll GradientGroupBox is...
14 Jan 2011 by _Erik_
Use double buffer wherever you make graphics operations in the paint event.
14 Jan 2011 by dingelen
I've tried double buffering in all places, no improvement. Take a look at the code if you have the time.Thnx
18 Oct 2014 by Marco Bertschi
A short guide on how you can style and customize the appearance of you QML controls in a CSS-like way
12 Dec 2013 by Nirosh
Architecting a Windows Forms based system on top of a framework. This will help you develop a form based application faster.
25 Feb 2012 by BrianLaF
Time Picker Extender User Control for ASP.NET Framework 4
9 Aug 2013 by Ahmad Abd-Elghany
hello , every body use the grid view control in his project extremely , at least i do so.i put a nice style to my grid and i erased the borders and cell spacing etc .i also bind it from my db with stored procedure .i write the paging method and the page index changing method etc .now...
9 Aug 2013 by Mahesh Bailwal
You can not make change in HTML of user control from Parent Page at desgin time. If you need to add any column in user control gridview at design time then you need to do it directly in user control .ascx file .All the changes you made will be visible in every page where you use this user...
15 Dec 2011 by Member 3055661
Hello,I am trying to drop a server-side control onto a Google Map via an update panel (with viewstate enabled), and need it to behave like a map overlay (tied to coordinates on the map and pans with the map). Is that possible?So far, here is what I have:- Update panel on aspx page,...
15 Dec 2011 by Ganesan Senthilvel
Google API via JQuery is referred at http://www.sitepoint.com/google-maps-api-jquery/[^]
2 Oct 2013 by Member 3521466
How to check if a user control is loaded for the first time in a page? Ispostback is always true for the usercontrol.
16 Dec 2011 by Henryk Filipowicz
A web user control for selecting a file from the file system.
19 Jan 2012 by janwel
Hello fellow programmers, got a few problem here. I am adding a user control inside a gridview Now my question is how can bind it cause inside the user control is a gridviewthat needs the CourseCatID so that it could bind the datas. And by the way I cannot use nested griview cause I need the...
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 = ...
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 janwel
Ive got it but thanks anyway for your help. Ive created a sub wherein i get the coursecatidhere is my codePrivate Sub CreateCourseGrid(Optional ByVal parentIsPostBack As Boolean = False) 'Dim c As Control = GetPostBackControl(Page) 'If c Is Nothing Then For...