Click here to Skip to main content
15,885,835 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,
i created my own combo box
using edit box, down arrow button and list control
and the contents of the list control are like
+Type1
+Type2
-Type3
Name1
Name2
+Type4

when i click on the down arrow button then it shows the list control but when i click on the '+ Type2' sign then it moves the focus to the control below that '+ Type2'.

below the list control there might be some controls, so when i click inside the list control
and below that item if there is any control then focus moves to that control instead of the list control.

what should i do for this case?

when i click inside the list control to select an item in it then it should select that item irrespective of whether
there is a control below that clicked item or not.
How to do this?

so i want to show the list control having the functionality like list box of the combo box.
(when i click on the down arrow button it is showing the list control but there are some control behind this list control so when select the item in the list control then focus moves to the control which is behind the list control
so i don't want this, it should not focus the control behind the list control. what should i do?)
waiting for the reply.
Posted
Updated 1-Dec-11 4:15am
v4
Comments
Albert Holguin 1-Dec-11 9:45am    
It's had to understand what you mean by "when I click on the '+ Type2' sign then it move the focus...". What '+ Type2' sign?
sunnyram 1-Dec-11 10:17am    
(it is the item in the list control)i updated the question, please check it, waiting for the reply.
Richard MacCutchan 1-Dec-11 11:01am    
Why not use a proper ComboBox and avoid all this extra work?
sunnyram 2-Dec-11 1:01am    
i want to do many things in the list control, means on double click in some cell of the list control i want to show combo box or edit box as per the sub-item index such things can not be done in combo box. so using the list control for this case.
Resmi Anna 2-Dec-11 1:14am    
ok...check whetehr it helps u..

1 solution

what you require seems to be a bit crazy. So here is a crazy solution to it:)

When you click on the down arrow button, u are displaying the list box on top of some control(s) rttt??.

so at that time hide the control under the list box and show the list box.

C++
MyCRAZYDlg::OnDownArrowBttnClck()
{
.....
GetDlgItem( IDC_MY_CNTRL  )->ShowWindow( SW_HIDE );
GetDlgItem( IDC_MY_LISTBOX )->ShowWindow( SW_SHOW );
.......
}

when u select something from the list box you want the selected item to be displyed in the edit box and hide the list box rttt??
at that time show the control(s) under the list box and hide the listbox....
C++
MyCRAZYDlg::OnSelchangeList()
{
.....
GetDlgItem( IDC_MY_CNTRL  )->ShowWindow( SW_SHOW );
GetDlgItem( IDC_MY_LISTBOX )->ShowWindow( SW_HIDE);
.......

}
 
Share this answer
 
Comments
sunnyram 2-Dec-11 3:00am    
yes, instead of hiding we can disable the controls to make this work, but this will be my last option to solve my problem.
is there any other way to solve my problem. because i am going to use this combo box in 2-3 places so instead of disabling/hiding the controls, is there any other solution? in standard combo box, it shows the list box it does not disable/hide the controls bellow it so if i want to give this functionality to my combo box then how do i do this?
Resmi Anna 2-Dec-11 5:40am    
could not find any other solution:( the list box that comes down with the MFC combo box looks different from the normal list box.se its boarder....can make a try using owner draw list box..not sure whether it works....no way to get its style using winspy also..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900