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
47
votes
4 answers

Exposing events of underlying control

I have a combobox in a custom control. How can I expose specific events from it such as SelectedIndexChanged or KeyPress, etc to anyone/thing implementing my custom control?
Malfist
  • 31,179
  • 61
  • 182
  • 269
46
votes
3 answers

Data Binding in WPF User Controls

I am creating a UserControl for a series of controls shared by several windows. One of the controls is a Label which shows the flow of some other process in terms of "protocol numbers". I am trying to offer DataBinding with this Label so the Window…
M Rajoy
  • 4,028
  • 14
  • 54
  • 111
44
votes
2 answers

Exposing inner Control properties for binding in WPF

[Edit]: I figured out how to do this on my own. I posted my solution in the hope that it will save someone else a few days of Googling. If you are a WPF guru, please look at my solution and let me know if there is a better / more elegant / more…
fbl
  • 2,840
  • 3
  • 33
  • 41
43
votes
9 answers

Abstract UserControl inheritance in Visual Studio designer

abstract class CustomControl : UserControl { protected abstract int DoStuff(); } class DetailControl : CustomControl { protected override int DoStuff() { // do stuff return result; } } I dropped a DetailControl in…
user356178
43
votes
10 answers

Calling a method in parent page from user control

I've a user control registered in an aspx page On click event of a button in the user control, how do i call a method which is there in the parent page's codebehind? Thanks.
Jeremy Thomson
  • 999
  • 3
  • 16
  • 17
43
votes
4 answers

Loaded event of a WPF user control fires more than once

To implement a tab-based environment in WPF we need to convert our forms to user controls, however when doing this, the Loaded event of the user control is called two times. While searching on the internet other people also pointed this issue. How…
Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
43
votes
2 answers

WPF ControlTemplate vs UserControl

I've recently made an UserControl, which took quite a long time, because I had to work with custom Dependency Properties and so on... Anyways, it was just a bunch of 3 controls: TextBox, Popup with Hierarchical Tree. Now I realized I could probably…
theSpyCry
  • 12,073
  • 28
  • 96
  • 152
40
votes
3 answers

Difference between Resize and SizeChanged events

In C# .Net in Winforms, I found two events in almost all components, Resize() and SizeChanged(). Is there any difference between them? If both events are the same then why has C# provided two different events? I am creating a user control in C#. …
Haider Ali Wajihi
  • 2,756
  • 7
  • 51
  • 82
39
votes
18 answers

Can't set focus to a child of UserControl

I have a UserControl which contains a TextBox. When my main window loads I want to set the focus to this textbox so I added Focusable="True" GotFocus="UC_GotFocus" to the UserControls definition and FocusManager.FocusedElement="{Binding…
EightyOne Unite
  • 11,665
  • 14
  • 79
  • 105
39
votes
4 answers

How programmatically dock new element to DockPanel

How programmatically create an element based on UserControl and dock it to the DockPanel?
iLemming
  • 34,477
  • 60
  • 195
  • 309
38
votes
9 answers

Document.Ready() is not working after PostBack

I have a page that contains a user control within an update panel. $(document).ready(function() ) { is called and executes the code correctly when the page firsts loads but if the user clicks a button (within the user control), the document.ready()…
Theomax
  • 6,584
  • 15
  • 52
  • 72
38
votes
2 answers

add user control to a form

I have created a user control with a TextBox and two Buttons, but I haven't created events, just I place them to user control. When I want to add the user control to my form it says: Cannot move Task_control.cs. The destination folder is the same…
Viva
  • 1,983
  • 5
  • 26
  • 38
37
votes
1 answer

Control vs UserControl in WinForms?

What is the difference between a Control and a UserControl in .NET WinForms? I want to create a custom control, but which one should I inherit from? I've always used Control in the past without any issues, but is the "recommended" way of creating a…
Jon Tackabury
  • 47,710
  • 52
  • 130
  • 168
37
votes
8 answers

Cannot Place User Control on Form

I've created a C# WinForms application using VS2010. I'm new to creating user controls so I created a new user control (as part of the same project). When I rebuild the project, the new control appears in the toolbox. And when I drag the control…
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
37
votes
13 answers

Failed to load toolbox item. It will be removed from the toolbox

I have a WinForm application. I also have created my own User Control for it. Everything worked fine. Until today that I received the error message when I try to add it back to my program (I never removed it. Visual Studio did). Failed to load…
disasterkid
  • 6,948
  • 25
  • 94
  • 179