Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / August 2007

Tip: Looking for answers? Try searching our database.

Combobox does not hide selection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrus - 22 Aug 2007 17:21 GMT
I added a lot of myComboBox controls to form.
Every combobox shows all its content selected.
Selection is removed only when I tab off from the control.

How to hide selection initially?
There is not HideSelection property in Combobox.

Andrus.

class myComboBox : ComboBox {
 internal myComboBox(DataRow dr, DataTable table) {
  DisplayMember = "DisplayMember";
  ValueMember = "ValueMember";
  DataSource = lookup.GetPickList();
  DataBindings.Add("SelectedValue", table,
                    dr["controlsrc"].ToString());
  AutoCompleteSource = AutoCompleteSource.ListItems;
  AutoCompleteMode = AutoCompleteMode.SuggestAppend;
}}
Kevin Spencer - 23 Aug 2007 12:55 GMT
Set the focus on another Control.

Signature

HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

>I added a lot of myComboBox controls to form.
> Every combobox shows all its content selected.
[quoted text clipped - 15 lines]
>   AutoCompleteMode = AutoCompleteMode.SuggestAppend;
> }}
Andrus - 23 Aug 2007 18:46 GMT
Thank you.

I add combo boxes programmatically in a loop in UserControl constructor.
Should I set focus in constructor ?

My form creation code is:
class LayoutUserControl : UserControl {

public LayoutUserControl(Control container, int layoutNumber,

                         DataTable table, string formSource, char
tableType) {

container.SuspendLayout();

int tabI = 1;

foreach (DataRow dr in desktop.DataSet.Tables[0].Rows) {

Control control;

myComboBox  myComboBox = new myComboBox(dr, table);

control = myComboBox;

control.TabIndex = tabI++;

elem.control = control;

container.Controls.Add(elem.control);

flds.Add(elem);

}

container.ResumeLayout();

}

> Set the focus on another Control.
>
[quoted text clipped - 17 lines]
>>   AutoCompleteMode = AutoCompleteMode.SuggestAppend;
>> }}
Kevin Spencer - 24 Aug 2007 13:15 GMT
Set the focus at the end of the loop.

Signature

HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

> Thank you.
>
[quoted text clipped - 56 lines]
>>>   AutoCompleteMode = AutoCompleteMode.SuggestAppend;
>>> }}
Andrus - 24 Aug 2007 14:19 GMT
Kevin,

thank you. I added
myComboBox.Focus();

immediately after line

container.Controls.Add(elem.control);

inside combo boxes creation loop.

However texts in all combo boxes are still selected.

What I'm doing wrong ?

Andrus.

> Set the focus at the end of the loop.
>
[quoted text clipped - 58 lines]
>>>>   AutoCompleteMode = AutoCompleteMode.SuggestAppend;
>>>> }}
Kevin Spencer - 27 Aug 2007 11:34 GMT
I told you to (1) Set the Focus on some other Control than the ComboBox, and
(2) to do it "at the end of" the loop, meaning *after* the end of the loop.
The ComboBox is already getting the Focus. You want to put the Focus
elsewhere.

Signature

HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

> Kevin,
>
[quoted text clipped - 75 lines]
>>>>>   AutoCompleteMode = AutoCompleteMode.SuggestAppend;
>>>>> }}
Andrus - 27 Aug 2007 15:51 GMT
Kevin,

thank you for your patience.

I added  Focus();  outside the loop, after container.ResumeLayout() line.
I also tried to add Focus(); to textbox control outside the loop.

All texts in all combo boxes are still selected in all cases.

What I'm doing wrong ?

Andrus.

>I told you to (1) Set the Focus on some other Control than the ComboBox,
>and (2) to do it "at the end of" the loop, meaning *after* the end of the
[quoted text clipped - 81 lines]
>>>>>>   AutoCompleteMode = AutoCompleteMode.SuggestAppend;
>>>>>> }}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.