I have several System.Windows.Forms.Combobox whose dropdowns close when I click on the scrollbar. I can use the arrow to scroll to the bottom, then it allows me to click and drag the scrollbar. The dropdown also disappears sometimes when I click between the bar and the arrows, although sometimes it doesn't. I've tried changing a lot of parameters but to no avail. Scrolling with the mouse wheel works perfectly. This seems like a bug, has anyone come across it?
I have turned off all event handlers for the combobox and it still shows the same behaviour.
This is the Designer code for the combobox (cmbSubmit):
this.cmbSubmit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbSubmit.DropDownWidth = 620;
this.cmbSubmit.FormattingEnabled = true;
this.cmbSubmit.Location = new System.Drawing.Point(6, 30);
this.cmbSubmit.Name = "cmbSubmit";
this.cmbSubmit.Size = new System.Drawing.Size(620, 33);
this.cmbSubmit.TabIndex = 0;
And the code where I add items to the combobox:
cmbSubmit.Items.Clear();
for (int i = 0; i < 100/*numItems*/; i++)
{
cmbSubmit.Items.Add("" + i);
}
Any help would be greatly appreciated, thanks in advance.
Related
I have a quite complex GUI in unity whit public override void OnInspectorGUI().
For all of my normal fieds I can add a tooltip with the header: Tooltip[("")] in the class itself.
However, I need a dynamic dropdown list that needs to be updated with the number of elements of a list.
I works great. Find the code of the custom editor script for the dropdown list:
string[] options = new string[movParamsListSize];
for (int i = 0; i < movParamsListSize; i++)
options[i] = i.ToString();
Rect r = EditorGUILayout.BeginHorizontal();
movStepToMoveTo.intValue = EditorGUILayout.Popup("movementStepToMoveTo",
movStepToMoveTo.intValue, options, EditorStyles.popup);
EditorGUILayout.EndHorizontal();
Find also a screenShot:
My problem is that I tried with all the overloaded functions of the EditorGUILayout.Popup() function (image below from the metadata) and cannot figure out how to add a tooltip when the mouse hovers to this control.
Any help is much apprecciated. Many thanks
Use the overload of EditorGUILayout.Popup that takes a GUIContent instead:
EditorGUILayout.Popup(new GUIContent("movementStepToMoveTo", "YOUR TOOLTIP HERE"), movStepToMoveTo.intValue, options);
Btw the EditorStyles.Popup is redundant since this is the default for a Popup ;)
and also HorizontalGroup is quite redundant here. You have only one control anyway.
This is my code:
for (int i = 0; i < 30; i++)
{
FileListView.Items.Add(new ListViewItem(new[] { "asd1", "asd2" }));
if (i < 10)
{
FileListView.Items[i].Selected = true;
}
}
FileListView.ItemDrag += new ItemDragEventHandler(FileListView_ItemDrag);
but when I Run the application, I can't see the first 10 items selected. For see them, I need to click on one of them, and they will highlights (but of course deselected immediatly, since it is like click on a single row).
How can I preselect 10 items? So a user see them selected and then can click to drag/drop to some destination...
The items are being selected but the control is not activated. Use FileListView.Select() to activate the control.
It sounds like your ListView is not focused so when you select the items they won't highlight.
You can either focus the control before hand like this:
FileListView.Focus();
Or what's probably better is to disable the HideSelection property. This allows the ListView to display selected items when not focused.
FileListView.HideSelection = false;
Edit: With OPs new information that they need to show blue, give keyboard focus to the control once you're done:
FileListView.Select();
Did you set the multiselect property with the designer or by code ?
FileListView.MultiSelect=true ;
Try also:
FileListView.Invalidate() after the loop.
Good day all.
I have an issue with using the ListView control in C#:
I can create an Object of it and at least from what the debugger says (nothing) I can also add items and columns and all. However:
I cannot see the ListView at all.
Below the code with which I want to draw it onto an otherwise emtpy Form:
private ListView auftraegeView;
And then inside the constructor, after InitializeComponent:
auftraegeView = new ListView();
auftraegeView.View = View.Details;
auftraegeView.Width = this.Width - 12;
auftraegeView.Height = this.Height - 20;
auftraegeView.Left = 6;
auftraegeView.Top = 14;
I tried .Show() and .Refresh() methods, but to no avail.
The problem is that you are not adding your control to your form. You have created the object but now you need to show it on the form. For that you have to add it to the list of controls that need to be shown on the forms.
Some thing like
yourFormName.Controls.Add(auftraegeView );
Have tyou tried BringToFront and checked that the prorperties Visible = true?
i Now is trivial but..
I have a winforms app and i have listview. Through the visual designer, I add a bunch of items and set the "checked" property to true on all of the items. When i start my app none of the items are selected which seems odd.
Even after I tried adding this code:
for (int i = 0; i < listView1.Items.Count; i++)
{
listView1.Items[i].Selected = true;
}
when i startup my app (its a vsto app), none of the items are selected. I am choosing LargeIconView (not sure if that makes a difference)
How can i default a listview to have all items checked by default at startup?
The reason your code isn't working is because the ListView control doesn't have focus. Two things you could do are to
1) Set the TabIndex property of the control to be the lowest on the form (likely 0)
2) Select the ListView programmatically
private void Form1_Load(object sender, EventArgs e)
{
listView1.Select();
for (int i = 0; i < listView1.Items.Count; i++)
{
listView1.Items[i].Selected = true;
}
}
The checked property is relevant only if the ListView's property of CheckBoxes is set to True. Checked is not the same thing as Selected.
Your code to select all the items works for me. But perhaps, as keyboardP suggests, your issue is related to Focus. Edited: Yes, it only works because I am testing it and this is the only control on my form.
"How can i default a listview to have all items checked by default at startup?"
Change:
listView1.Items[i].Selected = true;
To:
listView1.Items[i].Checked = true;
Not sure why the setting isn't "sticking" if you already set them all to checked thru the IDE. Are you modifying the contents of the ListView when the form is loading?
i am using .NET CF making application in window mobile.
need want to add textboc in third column of listview.
googled it but only getting solution for web application.
aint it possible in window mobile ????
code i tried so far... (although it is not working :-) )
for (int i = 0; i < soups.Length; i++)
{
ListViewItem li = new ListViewItem();
li.Text = "RSO" + (i+1);
li.SubItems.Add(arrval[i]);
//in 1st attemp i tried
li.SubItems.Add(new TextBox());
//in 2nd attemped
TextBox tbox = new TextBox();
li.SubItems.Add(tbox);
li.SubItems.Add(Convert.ToString(5 * (i + 1)));
li.SubItems.Add(Convert.ToString(35 * (i + 1)));
lst_option.Items.Add(li);
}
but both ways not working.... bcz of obvious reasons as i am trying to add obj in add() method instead of string :) :)
thnkx in advance
None of the out-of-the-box controls for the Compact Framework (ListView, ListBox, DataGrid, etc) provide this capability. The common work-around is to place a separate TextBox on the form and when a ListViewItem is selected, move the Textbox to cover the location of the subitem/cell, put the subitem/cell text into the TextBox, then make it visible.