By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,621 Members | 1,087 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,621 IT Pros & Developers. It's quick & easy.

Combobox Problem

100+
P: 123
hi,

I have one combobox. There are 5 items in it.
Gujarat
Maharashtra
Mumbai
Delhi
Deharadun

When i click on combobox and when i press M key from keyboard control should go to items starting from M. How to do code for this?
Mar 14 '07 #1
Share this Question
Share on Google+
20 Replies


vijaydiwakar
100+
P: 579
hi,

I have one combobox. There are 5 items in it.
Gujarat
Maharashtra
Mumbai
Delhi
Deharadun

When i click on combobox and when i press M key from keyboard control should go to items starting from M. How to do code for this?
set its sorted property to tru..
type M and press dwn arrow key
ur at the first point
Mar 14 '07 #2

Expert 5K+
P: 8,434
...When i click on combobox and when i press M key from keyboard control should go to items starting from M. How to do code for this?
This will work if you set the .Style property to 2 - Dropdown List.
Mar 14 '07 #3

100+
P: 123
This will work if you set the .Style property to 2 - Dropdown List.

After setting to it, how to write the code. I want to do like same as done in VB. When popup window is displayed in VB, and when i press first letter, all the items in that list get selected and control directly goes to the first item in the list.
Mar 15 '07 #4

Expert 5K+
P: 8,434
After setting to it, how to write the code. I want to do like same as done in VB. When popup window is displayed in VB, and when i press first letter, all the items in that list get selected and control directly goes to the first item in the list.
You haven't said what version of VB you're using.

In VB6, there's nothing to code - the combobox just works that way.
Mar 15 '07 #5

100+
P: 123
You haven't said what version of VB you're using.

In VB6, there's nothing to code - the combobox just works that way.

I am using VB6.
Mar 20 '07 #6

Expert 5K+
P: 8,434
I am using VB6.
So, have you tried my suggestion?
Mar 21 '07 #7

100+
P: 123
So, have you tried my suggestion?

it does not work.
Mar 21 '07 #8

samycbe
P: 83
in vb6,

select the combobox style 2 - Dropdown combo.

it should work.......



samy
Mar 21 '07 #9

Expert 5K+
P: 8,434
in vb6,

select the combobox style 2 - Dropdown combo.

it should work.......
That's what I said.
Mar 21 '07 #10

100+
P: 123
That's what I said.

It does not work. Contorl does not go directly to that item. I have to press down arrow key. That i dont want.
If combo contains following items:

Gujarat
Maharashtra
Mumbai
Raipur
Rajasthan

When i press m and down arrow key, maharashtra gets selected. I dont want that. What I want is when i press m maharashtra should get highlighted.
Mar 23 '07 #11

Expert 5K+
P: 8,434
Actually, I suggested style 2 - Dropdown List, not Dropdown Combo as Samycbe said. Which one are you using? I have just tested again, and 2 definitely works as you describe. The potential drawback, of course, is that you cannot type anything other than what's in the list. Is that a problem?
Mar 23 '07 #12

100+
P: 123
Actually, I suggested style 2 - Dropdown List, not Dropdown Combo as Samycbe said. Which one are you using? I have just tested again, and 2 definitely works as you describe. The potential drawback, of course, is that you cannot type anything other than what's in the list. Is that a problem?
I have changed it to 2 Drop Down List. It does not work.
Mar 23 '07 #13

Expert 5K+
P: 8,434
I have changed it to 2 Drop Down List. It does not work.
That's really weird. What happens when you first press "m"? On my system, if I add that list of cities to a combobox with style 2, then press "m" it jumps to the first city starting with "m". As I knew it would. I don't know why your would be acting differently.

Try this exercise. Create a new project with just Form1, and add a combo box to the form, and set its Style property to 2. Then paste this into the code window for the form, replacing anything already there. Give it a run, and tell us what happens when you press "m".
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. DefLng A-Z
  3.  
  4. Private Sub Form_Load()
  5.   With Combo1
  6.     .AddItem "Gujarat"
  7.     .AddItem "Maharashtra"
  8.     .AddItem "Mumbai"
  9.     .AddItem "Raipur"
  10.     .AddItem "Rajasthan"
  11.   End With
  12. End Sub
Mar 23 '07 #14

P: 3
Hi
I m creating a Visual C# application.
I have XML file .
<?xml version="1.0" encoding="utf-8" ?>
- <FilterType>
<Type>Scheduling Requests</Type>
- <Fields>
- <Field>
<Name>Upper Tier Hearing</Name>
<DataType>String</DataType>
<DBField>UTHearing</DBField>
</Field>
- <Field>
<Name>Complexity</Name>
<DataType>String</DataType>
<DBField>Comp</DBField>
</Field>
</Fields>
<Type>Member Availability</Type>
- <Fields>
- <Field>
<Name>XTXTX</Name>
<DataType>String</DataType>
<DBField>XTXTX</DBField>
</Field>
- <Field>
<Name>TComplexity</Name>
<DataType>String</DataType>
<DBField>TComp</DBField>
</Field>
</Fields>
</FilterType>

i want to add Name field as an item in combobox .so that i can use this combobox as a filter for my database query.
Can u Pls help me out??
Thanks
Himani
Mar 23 '07 #15

Expert 5K+
P: 8,434
Hi
I m creating a Visual C# application.
I don't think the VB forum is really the appropriate place for your post, then. You probably should ask your question somewhere like the C++ or Miscellaneous forum.
Mar 25 '07 #16

100+
P: 123
That's really weird. What happens when you first press "m"? On my system, if I add that list of cities to a combobox with style 2, then press "m" it jumps to the first city starting with "m". As I knew it would. I don't know why your would be acting differently.

Try this exercise. Create a new project with just Form1, and add a combo box to the form, and set its Style property to 2. Then paste this into the code window for the form, replacing anything already there. Give it a run, and tell us what happens when you press "m".
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. DefLng A-Z
  3.  
  4. Private Sub Form_Load()
  5.   With Combo1
  6.     .AddItem "Gujarat"
  7.     .AddItem "Maharashtra"
  8.     .AddItem "Mumbai"
  9.     .AddItem "Raipur"
  10.     .AddItem "Rajasthan"
  11.   End With
  12. End Sub
It is done with Style 2. But is it possible to do the same thing with style 0. Bcoz in style 2, i am not able to set Text property. Can u tell me same thing with style 0
Mar 27 '07 #17

P: 3
just check there whether the press character frm keyboard is M or not
that's it ??
Mar 27 '07 #18

100+
P: 123
It is done with Style 2. But is it possible to do the same thing with style 0. Bcoz in style 2, i am not able to set Text property. Can u tell me same thing with style 0

It is done with Style 2. But is it possible to do the same thing with style 0. Bcoz in style 2, i am not able to set Text property. Can u tell me same thing with style 0
Mar 27 '07 #19

P: 24
Thats very simple, try going to the properties of the combobox u r talking about and u have a sorting options, make that to TRUE and give it a try, hope u will get the results u r looking for...
cyaa - subbu

hi,

I have one combobox. There are 5 items in it.
Gujarat
Maharashtra
Mumbai
Delhi
Deharadun

When i click on combobox and when i press M key from keyboard control should go to items starting from M. How to do code for this?
Mar 27 '07 #20

Expert 5K+
P: 8,434
It is done with Style 2. But is it possible to do the same thing with style 0. Bcoz in style 2, i am not able to set Text property. Can u tell me same thing with style 0
Are you sure you need to set the Text property? Does that mean you don't want input to be limited to what is in the list?

If you do want input to be restricted to only what's in the list, then you can use Style 2, and rather than setting .Text, you set .ListIndex to point to the item you want.

If you want to allow entries that are not in the list, then... hm... I do remember seeing some code years ago which was intended to do this "search as you type" behaviour in a combobox. I'd suggest you try some searches on Google or somewhere for various key terms, and try to track it down. I think it just involves one or two API calls.

I might be able to have a bit of a look for it at lunch time, which is in a few hours. But I can't guarantee anything.
Mar 27 '07 #21

Post your reply

Sign in to post your reply or Sign up for a free account.