Click here to Skip to main content
15,893,368 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 Updated

User Controls 

4 Jun 2010 by #realJSOP
Are you adding these controls dynamically, or at design time?
4 Jun 2010 by #realJSOP
The problem I think is that your tiNew variable is being reallocated, so the program has the same tab twice. You sholud write a method that creates a new TabItem and sets all the appropriate properties, and returns the TabItem to be added to the TabControl.Items collection.
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...
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[^]
2 Sep 2011 by #realJSOP
You want a RequiredFieldValidator.http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.requiredfieldvalidator.aspx[^]
1 Dec 2011 by #realJSOP
Anything defined as protected or public in an object will be visible in intellisense. Beyond that, you don't necessarily want to change the accessibility of protected or public methods because - well - it makes more sense for them to be public or protected.
21 Jul 2014 by #realJSOP
I'm using VS2013 and have setup a tab control with each tab item containing a UserControl. Intellisense sees it when I add it in the XAML, but the compiler is insisting that a user control doesn't exist in the namepace, yet the the app compiles and runs as expected. Does anyone have any idea...
21 Jul 2014 by #realJSOP
The solution was to add the assembly name to the namespace declaration in the xaml - but I'm not sure why that was necessary when the control is in the same freaking assembly as the window that's using it (which also happens to be the application exe).(Reason for edit - fixed some spelling...
5 Nov 2018 by #realJSOP
Create a static class that contains the desired user data. When the user logs in, capture the desired user data into your static class, and you can still return a bool from your login method.
7 Nov 2012 by -Dr_X-
Below is a inherited winforms control with two buttons.The code, 'Me.ParentForm.AcceptButton' errors during design time. I've tried the DesignerSerializationVisibility tag as well as the LicenseUsageMode with no luck to prevent it from running when opening a user control that is inherits...
8 Nov 2012 by -Dr_X-
After a bit more research, I found this is a prevalent issue with the work-around below. Basically, avoid having any handles clauses from your base class.Public Class CalculationPanelBase Private Sub CalculationPanelBase_Load(sender As Object, e As EventArgs) Handles...
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...
20 Nov 2014 by /\jmot
Links..http://stackoverflo...
22 Jun 2011 by 2irfanshaikh
i think we can use DataGrid.SelectedCells.Also check this link[^].
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...
1 Mar 2014 by _Asif_
Try thisListBox with Custom Scrollbar[^]
14 Jan 2011 by _Erik_
Use double buffer wherever you make graphics operations in the paint event.
29 Oct 2013 by _Maxxx_
I guess your second user control is displaying data from the selected item in the list box?If so, then binding the listbox's SelectedItem property to your ViewModel will tell you if something is selected and, if so, what it is.You could then bind the visibility of your second user...
4 Dec 2011 by A Unique Name That Noone Else In Their Right Mind
Hi,I'm working on a small web application that is exhibiting some odd behaviour. My whole approach is probably not the best, and I don't know how much that contributes to the problem.What I am attempting to do:It's a basic timesheet entry page. I have a calendar control and I've...
13 Nov 2010 by a_pess
Alternative For VB.NET Windows Forms Private Sub ControlEnabled(ByVal ctrl As Control, ByVal isDisable As Boolean) Me.ControlEnabled(ctrl, isDisable, True) End Sub Private Sub ControlEnabled(ByVal ctrl As Control, ByVal isDisable As Boolean, ByVal allowRecurse As...
25 Sep 2020 by Aaron Bane
In the aspx page I am calling the the user control two times. On page load 1 usercontrol will be visible but the the other will be visible on button click and it should show only book description and book title. To achieve this I named the class...
5 Sep 2012 by Aarti Meswania
you can create custom event of your custom-controland raise that event from radio-button's checked eventHappy coding!:)
25 Sep 2012 by Aarti Meswania
inside label's click event UserControl1 obj=(UserControl1)yourLable.parent;In short .Parent is a property you are searching for,Control.parent returns it's parent controlsuppose,cont2 is placed inside con1 so, Cont2.parent will return cont1Happy Coding!:)
7 Oct 2012 by Aarti Meswania
vCurrent = Math.Round(Convert.ToDouble(uscontrTextbox.txt) * velocity, 4);orinstead of, this.uscontrTextbox.txt = ""; use,this.uscontrTextbox.txt = 0;Happy coding!:)
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...
22 Apr 2014 by abdul subhan mohammed
Hi guys,I have user control which contains:one dropdownlist n a textbox.i have to populate the dropdownlist in the user control n have to write the "onselectedindexchange" to fill the textbox which in the user control it self., event.n i'm placing this web user control in a...
14 Aug 2016 by abdul subhan mohammed
try thisprotected void GridView1_RowEditing(object sender, GridViewEditEventArgs e){ GridView1.EditIndex = e.NewEditIndex; FillGrid();}
30 May 2010 by Abhinav S
Matchlighter wrote:with a certain control of mineDoes this control reference another assembly that you need to add to this project?
8 Aug 2011 by Abhinav S
Some walkthroughs that will surely help you out -http://msdn.microsoft.com/en-us/library/a6h7e207%28v=VS.100%29.aspx[^]http://msdn.microsoft.com/en-us/library/5h0k2e6x%28v=VS.100%29.aspx[^]
20 Oct 2011 by Abhinav S
TryASP.NET - Drag and Drop on a Webpage[^]http://msdn.microsoft.com/en-us/magazine/cc135985.aspx[^] (with Ajax)http://weblogs.asp.net/hpreishuber/archive/2007/12/22/ajax-drag-amp-drop-challenge.aspx[^] (again with Ajax)
3 Dec 2011 by Abhinav S
You can use the sealed modifier (as described here[^]) in your custom control.
12 Feb 2012 by Abhinav S
Instead of trying Me.Parent, tryDim myParent as Page = this.Page;Dim DaTxtBox As TextBox = myParent.FindControl("textbox1")
21 Jul 2014 by Abhinav S
Try cleaning the solution and then do a build.
9 May 2015 by Abhinav S
Answers from here[^] might help you.
15 Apr 2014 by abhiSek99
Hi All, i want to create normal gridview user control in c# asp.net., which can be used in other aspx pages.please suggest me some links on the same
21 Sep 2013 by Abhishek Luv
Issue : When the user is writing some text in the textarea(UserControl2) and in between when he tries to click anyone of the Radiobutton(from UserControl1) the page is posted back and the text value of the textarea is lost. I have also enable viewstate for the textarea.Please guide me. How...
22 Oct 2012 by Abhishek Pant
1. Add image to BackgroundImage property of button.2. Add a tooltip to the button.3. Find the property 'ToolTip on toolTip1' (the name may not be toolTip1 if you changed it's default name).Now write "Edit"(as according to your requirement or anything you write will be popped out) on the...
3 Sep 2012 by Abolfazl Beigi
Hello my friends.I have a page here that include a js file and it works fine, i used it for make an animated div for its size dynamically. but the problem is when i make a user control it doesn't work, means my jquery codes becomes unusable and cant animate related Div.Thanks for your...
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 ...
2 Oct 2014 by Adam Zgagacz
WinForms Scrollbar with enhanced properties, graphical bookmarks and value tooltips.
31 Oct 2018 by Adam Zgagacz
Simple WinForms auto-repeat button in a few lines
5 Nov 2019 by Adnan Maruf
So i've a Form1 with three UserControl's as UC1,UC2 & UC3. Form1 contains a Button, UC1 and UC3. Both UC1 & UC3 are initially hidden when the application runs and the Form1 button click event makes the UC1 visible. UC1 contains a panel and inside the UC1 load event I'm adding UC2 into the panel...
31 Oct 2012 by adriancs
What user control is that?Is it a Windows Application or Web Application?You can use Properties of Visible to hide or show the control.protected void Button1_Click(object sender, EventArgs e){ userControl1.Visible = !userControl1.Visible;}
17 Aug 2013 by adriancs
An Office 2010 Style Color Picker for .NET WinForm.
12 May 2012 by Aero72
Dear all,I hope I'm not about to poperly fall at the final fence - hopefully someone can point me in the right direction...I have a flow layout panel into which I'm putting many instances of a user control. This control (for now) just has a check box and a few text fields only.The code...
12 May 2012 by Aero72
Sorry Mika, I still think I'm being thick (and thanks for formatting my code - I worked out how to do that now ;-)) - your assumption is correct. What I want to do is to parse through all the instances of my user controls and take various actions depending upon the values or state (in the case...
16 Mar 2013 by AfnanMof
This WebPart is developed to display all site collections and subsites based on logged in authentication
16 Feb 2015 by Afzaal Ahmad Zeeshan
I also tried to help you out on that Stack Overflow thread of your question, the problem actually is that you shouldn't actually ask the server-side code to take over the client-side code too. If you have to then you have to register the code at the start-up and then execute it. But, another...
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.
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...
28 Apr 2016 by Ahmad_kelany
Hello everyone,I have a UserControl library containing the following usercontrol : DisplayGridXAML :
28 Jan 2014 by Ahmed Bensaid
Take a look there ;)http://stackoverflow.com/questions/2867412/how-to-use-multiple-instances-of-a-usercontrol-with-jquery-on-the-same-page[^]
16 Sep 2010 by Ahmed_Said
Colorful Microsoft Windows Forms Controls
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.
14 Oct 2014 by Ajay Kumar
How to bind a dropdownlist inside a gridview in a user control where the parameter will be change for every page ? how to handle it with a .aspx page?
22 Nov 2017 by Akhil Jain
I have a .aspx page Contract.aspx in which there is a user control and the userControl has a grid. Now i want to bind the grid inside user control to save click on some condition .ascx partial...
7 Dec 2011 by Akos Orban
A TextBox for numbers with built-in mathematical expression evaluation
30 Dec 2013 by akqira
Hi,This is my solutionpublic void buttonClicked() // called by the button clicked event{ // looking for opened forms collection var _myForm = (MyForm)Application.OpenForms["myForm"]; if (_myForm == null) myForm = new myForm{ name = "myForm"}; ...
5 Sep 2010 by Al-Farooque Shubho
You need to provide the codes that are using the Usercontrol. I suspect, problem is in the consuming codes.May be you are setting the property with an instance of the UserControl and trying to get the property in another instance, instead of the instance that contains the property value...
17 Feb 2011 by Albin Abel
Instead of using images, you can use resizable graphics. As graphic (vector, not image) holds less data than image, operations would be faster. Take a look here for a resizable graphic with handlersA Resizable Graphical Rectangle [^]
7 Nov 2013 by Alexander Chernosvitov
ActiveX component for 3D visualization, embedded in different client applications.
17 Oct 2011 by Alexander Dickbauer2
How can i Enable this on a UserDefined Control?http://img32.imageshack.us/img32/9148/aufgabena.png[^]Thanks
5 Nov 2017 by Alexander Iacobciuc
In this article you will find yet another implementation of a web camera control.
23 May 2014 by ali majed
Hi to all!I created user control that contain ToolStrip and DGV and add it to form. I accessible ToolStrip by define as public properties public ToolStrip Toolbar { set { ToolBarToolStrip = value; } get { return ToolBarToolStrip; } ...
6 Aug 2013 by ali-rashidi
Here is my problem.I have a master page.I have an update panel in my master page.I have a default.aspx page which is content page of my master page.In my master page I have a link button, Once you click on that It creates a user control and adds it to my content page. ...
15 Nov 2012 by Ali_100
I am getting the error in user control ,it is a new project ,clients gave us.what is the issue?the image is ASP.NET - Couldn't resolve the error in user control[^].[edit]Formatted link and removed extra blank link.[/edit]
21 Oct 2013 by Ali_100
I have a Labelin aspx page ,I want to use access in ascx page how can I do that ?
23 Oct 2013 by Ali_100
I need some opinion, if I am using user control & aspx page, & i have the requirement to use aspx page's label depend on some condition of usercontrol.but page_load event of aspx page is fired first , then user control's page_load event fired, so how do you able to update the label of aspx...
25 Oct 2013 by Ali_100
How to access parent page label's text in user control but from javascript of user control?
20 Apr 2013 by Aliaa Ezzat
29 Mar 2012 by Alimjan Yasin
I want to design a UserControl and a ViewModel which represents this UserControl,I want to use this UserControl in MainWindow .my ViewModel has a ObservableCollection Atribute, I want to bind this Atribute to listbox inside UserControl , but it did not show any thing when MainWindow show...
29 Mar 2012 by Alimjan Yasin
I solved it by myself, DataContext is key for do that
24 Apr 2011 by Aman4.net
Hi All,I was trying to build a custom button control. I want to change it's Visible Property. I declared the public bool variable and Implemented that with get-set. Which is showing in Property Box of UserControl placed on Form.But It is not showing any effect while I change...
19 Oct 2011 by AmarSinghRawat
May be in 3rd aspx page there is also test() function. please check.
24 Apr 2011 by ambarishtv
try thispublic bool BtnVisibility { get { return this.button.Visible; } set { this.button.Visible = value; } }
1 May 2012 by amer shammout
I have created a wpf project this project create a grid and many controls in this grid and allow the user to change controls properties now i wont to generate a user control dynamically this user control contains the grid and it's controls how can i do this
26 Mar 2012 by Amir Mahfoozi
Put your styles in a UserControl.Resources section in your user control XAML :...your styles goes here...Hope it helps.
10 Feb 2012 by Amir Sacic
Hello !I just want to ask you a quick question.How to change userpasswords in Active Directory ...Every time i'll try to change, i get a COM-Exception Unkown errorpublic void ResetPassword(string userDn, string newpassword){ DirectoryEntry user = new...
28 Aug 2012 by AmitGajjar
Hi,When you have class with parametrized construction it must have default constructor in it. So your code should be like,public class repeaterCEA: RepeaterCommandEventArgs { public Int32 idLote { get; protected set; } // Default constructor added. ...
6 Sep 2011 by amitghorpade29
I have one user control, this have variouse textboxes.and I created property for per textboxlike this: public int Budget { get { return Convert.ToInt32(tbxBudget.Text.ToString()); } }and i added this user control on my page.And I want to access this textbox...
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
14 Jul 2010 by Andrei Scripniciuc
Does anyone have a suggestion for a method that can be used to decorate any user control to suggest it's state is 'busy'? I'm thinking of something more than simply changing the cursor.
25 Jul 2011 by AndrewR73
I created a custom Templated User Control, for the purpose of having a standard "container" to use around our web app, but allow whatever controls you want inside of it -- pretty much like a Template Column of a GridView/DataGrid. Problem I'm having is that when I place a DropDownList control...
26 Jul 2011 by AndrewR73
@mahabubur rahman:Simply removing the the using (DropDownList ddlColor = ((DropDownList)xpcColor.FindControl("ddlColor"))) statement will have absolutely no effect on the problem I stated. Actually, doing this would in fact have the effect of introducing a failure: the SelectedIndexChanged()...
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){ ...
15 Aug 2011 by AndrewR73
A few weeks back I created a Templated User Control, for the most part based on the example here: http://msdn.microsoft.com/en-us/library/36574bf6(v=VS.90).aspxThe difference is that I did not implement the "MessageContainer" class as I wanted just an empty template that I could add...
16 Aug 2011 by AndrewR73
Found the solution to the problem, which was how I was loading the TUC.Incorrect:xpcRegion = new ExpandCollapseRegion();Correct:xpcRegion = (ExpandCollapseRegion)LoadControl("ExpandCollapseRegion.ascx");Making this simple change took care of the problem. Also, found that I...
7 Oct 2012 by Andriks
A MessageBox replacement with some much needed extras
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.
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...
9 Jul 2015 by Andy Lanng
Hi,I have a user control that returns search results and adds them to an asp table. The results include dates. I have another user control that displays dates in a nice "calendar date" style.The results control works fine without the date controls.I instantiate the date control...
29 Apr 2014 by Angel Blandón
Hi, I have compositecontrol, this is a container, inside this compositecontrol i have a ascx control the problem is that custom properties of this ascx control are not preserved after postback.The ascx controls are dragged and dropped in design modeI hope you can help me with this...
17 Feb 2012 by Aniket Yadav
For Image Viewerhttp://www.c-sharpcorner.com/UploadFile/sthangaraju/ImageViewerinCSharp11262005063149AM/ImageViewerinCSharp.aspx[^]http://software.intel.com/en-us/articles/c-image-viewer-sample-application/[^]DICOM Image Viewer[^]For Document...
18 Feb 2012 by Aniket Yadav
http://msdn.microsoft.com/en-us/library/dd492135.aspx[^]