question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ComboBox focused last

See original GitHub issue

Hey, maybe I do something wrong but I have a problem that ComboBox is always focused last.

8SijcLCnp8

using System.Collections.Generic;
using NStack;
using Terminal.Gui;

namespace UICatalog.Scenarios {
	[ScenarioMetadata (Name: "ComboBox focus bug",
		Description: "Demonstrates ComboBox bug")]
	[ScenarioCategory ("Bug Repro")]
	public class ComboBoxBug : Scenario {
		public override void Setup ()
		{
			var typeRadioGroup = new RadioGroup (0, 0, new ustring [] {"Expense", "Income"}, 0);
			Win.Add (typeRadioGroup);

			var nameLabel = new Label ("Name") {
				X = Pos.Left (typeRadioGroup),
				Y = Pos.Top (typeRadioGroup) + 2
			};
			var nameTextField = new TextField ("") {
				X = Pos.Left (nameLabel),
				Y = Pos.Top (nameLabel) + 1,
				Width = Dim.Fill ()
			};
			Win.Add (nameLabel);
			Win.Add (nameTextField);

			var categoryLabel = new Label ("Category ComboBox") {
				X = Pos.Left (nameTextField),
				Y = Pos.Top (nameTextField) + 2
			};

			var categoryComboBox = new ComboBox () {
				ColorScheme = Colors.TopLevel,
				X = Pos.Left (categoryLabel),
				Y = Pos.Top (categoryLabel) + 1,
				Width = Dim.Fill (),
				Height = Dim.Fill (2),
			};

			categoryComboBox.SetSource (new List<string> () {
				"Cat 1",
				"Other category"
			});
			
			Win.Add (categoryLabel);
			Win.Add (categoryComboBox);
			
			var amountLabel = new Label ("Amount") {
				X = Pos.Left (categoryComboBox),
				Y = Pos.Top (categoryComboBox) + 2
			};
			var amountTextField = new TextField ("") {
				X = Pos.Left (amountLabel),
				Y = Pos.Top (amountLabel) + 1,
				Width = Dim.Fill ()
			};
			Win.Add (amountLabel);
			Win.Add (amountTextField);
			
			var saveButton = new Button ("Save") {
				X = Pos.Left (amountTextField),
				Y = Pos.Top (amountTextField) + 2
			};

			var cancelButton = new Button ("Cancel") {
				X = Pos.Right (saveButton),
				Y = Pos.Top (saveButton),
				Clicked = Application.RequestStop
			};

			Win.Add (saveButton);
			Win.Add (cancelButton);
		}
	}
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fergusonrcommented, Jul 6, 2020

Shift + Tab fixed in PR #710

1reaction
BDispcommented, Jul 4, 2020

Thank you for my part. It was what I suspected. This method removes a view and adds it on top of the other views and its index is changed. We will have to force it to maintain the same index. Thanks for the info.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Set focus back on a ComboBox if the value is incorrect
I am trying to set my ComboBoxes so that the user can either choose from the list or set their own value (the...
Read more >
ComboBox.Focused Property (System.Windows.Forms)
Gets a value indicating whether the ComboBox has focus.
Read more >
Combobox Pattern | APG | WAI
End (Optional): Either moves focus to the last option or, if the combobox is editable, returns focus to the combobox and places the...
Read more >
Thread: [RESOLVED] Setting focus to ComboBox
I'm trying to set the focus to a ComboBox on program startup. I have this code in my form load event: Me.ComboBox1.Focus() The...
Read more >
How to Set Focus to textbox after combobox selection
Hi, Just use the .SetFocus method once the control is visible. You can't set focus to an invisible control. A couple of things...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found