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

What is the difference between User Control, Custom Control and Component?

These are three different things you can add to a project and I am not quite sure if I understand the difference. They all seem to for example show up in the component toolbox when working with a Form. What are some common usage scenarios for each…
Svish
  • 152,914
  • 173
  • 462
  • 620
74
votes
14 answers

Get a Windows Forms control by name in C#

I have a ToolStripMenuItem called myMenu. How can I access this like so: /* Normally, I would do: */ this.myMenu... etc. /* But how do I access it like this: */ String name = myMenu; this.name... This is because I am dynamically generating…
user186249
73
votes
8 answers

Prevent class inheritance in C++

Recently one of my friend asked me how to prevent class inheritance in C++. He wanted the compilation to fail. I was thinking about it and found 3 answers. Not sure which is the best one. 1) Private Constructor(s) class CBase { public: static…
ring0
  • 791
  • 2
  • 7
  • 5
72
votes
9 answers

C# Get a control's position on a form

Is there any way to retrieve a control's position in a form, when the control may be inside other controls (like Panels)? The control's Left and Top properties gives me only it's position within it's parent control, but what if my control is inside…
Erlend D.
  • 3,013
  • 6
  • 37
  • 59
69
votes
6 answers

Windows Forms' CheckBox CheckedChanged vs. CheckStateChanged

Windows Forms' CheckBox control implements both CheckedChanged and CheckStateChanged events. As far as I can tell, both fire when the checked status of the checkbox is changed. CheckedChanged precedes CheckStateChanged, but other than that I see no…
BojanG
  • 1,872
  • 1
  • 15
  • 23
65
votes
8 answers

Text on a ProgressBar in WPF

This may be a no-brainer for the WPF cognoscenti, but I'd like to know if there's a simple way to put text on the WPF ProgressBar. To me, an empty progress bar looks naked. That's screen real estate that could carry a message about what is in…
Jacob Proffitt
  • 12,664
  • 3
  • 41
  • 47
63
votes
2 answers

Setting Button FlatStyle in WPF

I have just been learning about how styles and control templates in WPF can affect the appearance of buttons, I'm trying to set the Button's FlatStyle, in the resources I've seen I can't find anything that tells me how I can do this, in Windows…
MrEdmundo
  • 5,105
  • 13
  • 46
  • 58
61
votes
8 answers

How can I change the Java Runtime Version on Windows (7)?

How can I change the Java Runtime Version on Windows. I installed Java 7 for some tests, and now I need the old java6 as system default, but I don't want to uninstall the Java 7 (I need it for later tests). Can I change the system-used JRE in the…
tomkpunkt
  • 1,393
  • 2
  • 15
  • 24
56
votes
1 answer

Getting The Location Of A Control Relative To The Entire Screen?

Let's say I have a Control and its location is relative to its parent. If its embedded many times and is the great great great grandchild of the main form, how can I determine what its location is on my entire screen, not just its location in the…
sooprise
  • 22,657
  • 67
  • 188
  • 276
56
votes
14 answers

DataGridView - how to set column width?

I have a WinForms application with DataGridView control. My control has five columns (say "Name", "Address", "Phone" etc) I am not happy with default column width. I want to have more control over column appearance. What I want is to be able to do…
Captain Comic
  • 15,744
  • 43
  • 110
  • 148
54
votes
1 answer

Why will <%= %> expressions as property values on a server-controls lead to a compile errors?

This question is a result of what i noticed while trying to answer another question. And now im curious to know why leads to a compile error, and not to a visible TextBox as i would have…
Tom Jelen
  • 2,559
  • 1
  • 24
  • 23
48
votes
17 answers

Best way to access a control on another form in Windows Forms?

First off, this is a question about a desktop application using Windows Forms, not an ASP.NET question. I need to interact with controls on other forms. I am trying to access the controls by using, for example, the…
Dylan Bennett
  • 1,615
  • 3
  • 17
  • 20
48
votes
15 answers

How to access Winform textbox control from another class?

I have a winform called Form1 and a textbox called textBox1 In the Form1 I can set the text by typing: textBox1.text = "change text"; Now I have created another class. How do I call textBox1 in this class? so I want to change the text for textBox1…
Psychocryo
  • 2,103
  • 8
  • 26
  • 33
47
votes
2 answers

what is hypermedia , hypermedia controls, hypermedia formats

I'm currently reading "Rest in practice" book . I'm unable to understand the following terminology Hypermedia , hypermedia format, hypermedia controls, Domain application protocol. The author was suggesting need for domain specific hypermedia…
vishnu
  • 511
  • 1
  • 7
  • 10
45
votes
1 answer

How to set which control gets the focus on application start

For a C# Windows Forms application, how do I set the default focus to a given control when my application starts?
Dribbel
  • 2,060
  • 2
  • 17
  • 29