Questions tagged [controls]

Use this tag for programming scenarios related to controls (interactive elements of the user interface).

A control is an interface element that a computer user interacts with.
Common controls include:

  1. Window A rectangle that represents a "window" into a document, form, or design area.

  2. Text box A box in which to enter text or numbers.

  3. Button An equivalent to a push-button as found on mechanical or electronic instruments.

  4. Hyperlink Text with some kind of indicator (usually underlining and/or color) that indicates that clicking it will take one to another screen or page.

  5. Drop-down list A list of items from which to select. The list normally only displays items when a special button or indicator is clicked.

  6. List box A GUI widget that allows the user to select one or more items from a list contained within a static, multiple line text box.

  7. Combo box A combination of a drop-down list or list box and a single-line textbox, allowing the user to either type a value directly into the control or choose from the list of existing options.

  8. Check box A box which indicates an "on" or "off" state via a check mark ☑ or a cross ☒. Sometimes can appear in an intermediate state (shaded or with a dash) to indicate mixed status of multiple objects.

  9. Radio button A button, similar to a check-box, except that only one item in a group can be selected. Its name comes from the mechanical push-button group on a car radio receiver. Selecting a new item from the group's buttons also deselects the previously selected button.

  10. Cycle button A button that cycles its content through two or more values, thus enabling selection of one from a group of items.

  11. Datagrid A spreadsheet-like grid that allows numbers or text to be entered in rows and columns.

  12. Slider A bar that allows users to make adjustments to a value or process throughout a range of allowed values.

8394 questions
29
votes
14 answers

Avoid calling Invoke when the control is disposed

I have the following code in my worker thread (ImageListView below is derived from Control): if (mImageListView != null && mImageListView.IsHandleCreated && !mImageListView.IsDisposed) { if (mImageListView.InvokeRequired) …
Ozgur Ozcitak
  • 10,409
  • 8
  • 46
  • 56
28
votes
2 answers

Calling a Javascript function in the C# webBrowser control

I am using the webBrowser control in C# to load a webpage and need to call a JavaScript function that returns a string value. I got a solution to use the InvokeScript method, and I tried a lot, but everything has failed.
raki
  • 2,253
  • 8
  • 33
  • 42
27
votes
1 answer

Differences between Excel's Form Controls & ActiveX Controls

Why are there 2 types of controls available in Excel? (2 buttons, 2 combo boxes, 2 check box, etc...) What's the difference between Forms Controls and ActiveX Controls? Which one should I use? Some code samples I find online work with my…
ashleedawg
  • 20,365
  • 9
  • 72
  • 105
27
votes
4 answers

Why is the control inaccessible due to its protection level?

I'm trying to access a control's text property from program.cs and it says that it is inaccessible due to protected level. How can I fix this please?
user164203
  • 313
  • 1
  • 4
  • 7
27
votes
4 answers

When to add a Component Class vs User Control?

I have a general idea, and there are some obvious cases, but there are also some gray areas for me - when is it best to use to extend from a component and when is it best to create a user control? This pertains to a specific work problem I am…
alexD
  • 2,368
  • 2
  • 32
  • 43
27
votes
6 answers

Applying Styles To ListItems in CheckBoxList

How can styles be applied to CheckBoxList ListItems. Unlike other controls, such as the Repeater where you can specify , you can't seem to specify a style for each individual control. Is there some sort of work around?
Andrew Burgess
  • 5,300
  • 5
  • 30
  • 37
26
votes
2 answers

How to access a WPF control located in a ControlTemplate?

Usually, the WPF controls are declared in the .xaml files and not in the code behind (.xaml.cs files). However, sometimes I need to use some of those controls in code behind in order to manipulate them. How can I get the handle of such a control if…
Abtin
26
votes
2 answers

Change back button to arrow-down in Navigation Bar

I'm using an AppCompatDialogFragment to show a BottomSheetDialog. Clicking the back button on the Navigation Bar closes the BottomSheetDialog. I want to change the icon on the Navigation Bar from the back button to the 'arrow-down' icon. This is by…
Vlad
  • 988
  • 12
  • 18
26
votes
8 answers

How to access WPF MainWindow Controls from my own .cs file

I am a NOVICE and am very much struggling with what seems should be a very simple task. How do I modify a property of a MainWindow TextBlock, from another cs file. An exact code solution would be extremely helpful. Below is the stripped down code.…
John Wolfe
  • 261
  • 1
  • 3
  • 3
25
votes
2 answers

When should I use a Localize control instead of a Literal?

I recently became aware of the System.Web.UI.WebControls.Localize control in a lab for the ASP.NET 4.0 MCTS certification course. The purpose of this control is unclear to me. In the examples, the Literal control and the Localize control appear to…
kbrimington
  • 25,142
  • 5
  • 62
  • 74
25
votes
5 answers

How to rebuild the Visual Studio Toolbox?

The toolbox in Visual Studio Professional 2008 has somehow ended up with 12 instances of each control. They are just the standard controls, no third party controls, and I have no third party plugins. Is there a way to rebuild the toolbox to correct…
Travis Collins
  • 3,982
  • 3
  • 31
  • 44
25
votes
5 answers

VB.Net: Dynamically Select Image from My.Resources

I have a group of images in my My.Resources. I want to select select images to display dynamically at run time. How do I do this? 'Static (Compile time) Assignment UltraPictureBox1.Image = my.Resources.zoo_picture_1 'Dynamic (Runtime)…
Jeff
  • 8,020
  • 34
  • 99
  • 157
24
votes
3 answers

How to set a default Margin for all the controls on all my WPF windows?

I want to set a default Margin of 3 on all the controls I put on all my windows and be able to override this value just on a really few number of items. I've seen some approaches like doing styles but then I need to style everything, I would prefer…
Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
24
votes
3 answers

How to get combobox not to accept user input in Excel-Vba?

Does anyone know what the properties are in the combobox that I can manipulate in order not to allow the user to key/type in any data?
Vivian
  • 1,071
  • 5
  • 16
  • 29
24
votes
7 answers

How do I find out which control has focus in .NET Windows Forms?

How do I find out which control has focus in Windows Forms?
Jeff
  • 8,020
  • 34
  • 99
  • 157