Questions tagged [user-controls]

A UserControl is a separate, reusable input control that allows a user to interact with an application. User controls can be buttons, checkboxes, input text boxes, mice, keyboards, etc.

A UserControl is a separate, reusable input control that allows a user to interact with an application. User controls can be buttons, checkboxes, input text boxes, mice, keyboards, etc.

User controls only exist on graphical systems or applications. For example, a HTTP service application does not contain user controls; its input is usually by means of a configuration file or a separate application providing it input.

10278 questions
73
votes
29 answers

User Controls not showing up in the toolbox

I have some UserControls that I created in ProjectA. I have ProjectB that has a windows form that I want to put the controls on. Both of these projects are in a single solution. There's a reference to ProjectA from ProjectB so it can "see" the…
Robert Deml
  • 12,390
  • 20
  • 65
  • 92
70
votes
5 answers

WPF - Hosting content inside a UserControl

I'm trying to create a user control that has a Grid with two rows. the first row for a title and the second one for a content that will be defined outside the user control such as a Button in our example. Somehow I didn't get it to…
Erez
  • 6,405
  • 14
  • 70
  • 124
69
votes
1 answer

Create custom User Control for Acumatica

I am attempting to create a custom User Control that is usable in the Acumatica Framework. Documentation is very limited so I was hoping someone may have some experience/examples of how best to implement? It appears possible by creating a WebControl…
Anth12
  • 1,869
  • 2
  • 20
  • 39
68
votes
10 answers

How to calculate the sum of the datatable column in asp.net?

I have a DataTable which has 5 columns: ID Name Account Number Branch Amount The DataTable contains 5 rows. How can I show the sum of the Amount Column in a Label Control as "Total Amount"?
thevan
  • 10,052
  • 53
  • 137
  • 202
67
votes
2 answers

How do I access an element of a control template from within code-behind

I'm trying to access a user control which is inside the control template of a content control. Specifically:
Locksleyu
  • 5,192
  • 8
  • 52
  • 77
64
votes
8 answers

How do I add Dispose functionality to a C# UserControl?

I have a class which implements UserControl. In .NET 2005, a Dispose method is automatically created in the MyClass.Designer.cs partial class file that looks like this: protected override void Dispose(bool disposing) { if (disposing &&…
e-holder
  • 1,504
  • 4
  • 20
  • 33
64
votes
4 answers

check if user is logged in in user control Asp.net MVC

how can i check if a user is logged in in user control with asp.net mvc usually on a view page i use this <% if (User.Identity.IsAuthenticated) {%> //Do something <% } %> but i can't get this done on a user control
Hannoun Yassir
  • 20,583
  • 23
  • 77
  • 112
62
votes
7 answers

A 'Binding' can only be set on a DependencyProperty of a DependencyObject

From a custom control based on TextBox, I created a property named Items, in this way: public class NewTextBox : TextBox { public ItemCollection Items { get; set; } } When using the custom control in XAML, I cannot bind the property because it…
mgottschild
  • 1,015
  • 1
  • 9
  • 10
60
votes
6 answers

WPF: How do I set the Owner Window of a Dialog shown by a UserControl?

I've got a WPF application with these three types of things... WindowMain UserControlZack WindowModal UserControlZack1 sits on my WindowMain...
Zack Peterson
  • 56,055
  • 78
  • 209
  • 280
59
votes
10 answers

The type 'UserControl' does not support direct content

I have an Outlook 2013 and 2016 VSTO Add-in project and am trying to add a WPF user control to a custom task pane as described here. The problem I have is when I add the User Control (WPF) it generates me a WPF control with a grid, but automatically…
NAJ
  • 1,175
  • 2
  • 12
  • 22
59
votes
6 answers

Is there any difference between drop down box and combo box?

Is there any difference between drop down box and combo box [ HTML ]? Actually the point is, everytime i say something like: "there is some problem with the combo box", my senior says: "that's not a combo box that is a drop down", :)
Rakesh Juyal
  • 35,919
  • 68
  • 173
  • 214
52
votes
9 answers

WPF UserControl Design Time Size

When creating a UserControl in WPF, I find it convenient to give it some arbitrary Height and Width values so that I can view my changes in the Visual Studio designer. When I run the control, however, I want the Height and Width to be undefined, so…
Joseph Sturtevant
  • 13,194
  • 12
  • 76
  • 90
52
votes
4 answers

How to make user controls know about css classes in ASP.NET

Since there are no header sections for user controls in asp.net, user controls have no way of knowing about stylesheet files. So css classes in the user controls are not recognized by visual studio and produces warnings. How can I make a user…
Serhat Ozgel
  • 23,496
  • 29
  • 102
  • 138
51
votes
7 answers

How do I get the HTML output of a UserControl in .NET (C#)?

If I create a UserControl and add some objects to it, how can I grab the HTML it would render? ex. UserControl myControl = new UserControl(); myControl.Controls.Add(new TextBox()); // ...something happens return strHTMLofControl; I'd like to just…
Jon Smock
  • 9,451
  • 10
  • 46
  • 49
50
votes
3 answers

How do I raise an event in a usercontrol and catch it in mainpage?

I have a UserControl, and I need to notify the parent page that a button in the UserControl was clicked. How do I raise an event in the UserControl and catch it on the Main page? I tried using static, and many suggested me to go for events.
user677607