Click here to Skip to main content
16,005,473 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to start an existing windows service programaticallly Pin
Dave Kreskowiak7-Dec-05 2:32
mveDave Kreskowiak7-Dec-05 2:32 
Questionvbkeydelete got disable Pin
icDavid6-Dec-05 11:07
icDavid6-Dec-05 11:07 
QuestionProblem with "Cannot create ActiveX component" Pin
Doug Goulden6-Dec-05 11:05
Doug Goulden6-Dec-05 11:05 
Questioncombobox and datagrid need help Pin
AdeshSharma6-Dec-05 6:52
AdeshSharma6-Dec-05 6:52 
AnswerRe: combobox and datagrid need help Pin
dptalt7-Dec-05 2:13
dptalt7-Dec-05 2:13 
AnswerRe: combobox and datagrid need help Pin
AdeshSharma8-Dec-05 3:11
AdeshSharma8-Dec-05 3:11 
Questionbutton doesn't work as expected Pin
mattlove6-Dec-05 6:40
mattlove6-Dec-05 6:40 
AnswerRe: button doesn't work as expected Pin
Roy Heil8-Dec-05 5:28
professionalRoy Heil8-Dec-05 5:28 
mattlove wrote:
Run the form, type, "abc" in the comboBox, highlight the "abc", click on the Add button and the eventcode shows a selectionlength of 0.

TextBox1.Text = cboBox.SelectionLength

go through the same process and type Alt A, instead of clicking the Add button, and the eventcode shows a selectionlength of 3.


The reason for this is that when you click on the button, focus leaves the combobox, and nothing is selected anymore. Thus the "0". When you do an "Alt A", focus is still in the combobox, and you have three characters highlighted, you get a "3".

mattlove wrote:
i've also tried the other selection options, eg, selectedindex, and still get unexpected results.


You don't say anything about adding items to the combobox items, so I am assuming that it is empty. Thus, regardless of clicking the button, or doing an "Alt A", you will probably get a "-1".

I guess my question would be: What do you want to happen?

Let's assume that you want the Add button to add the item to the combobox list. In the button click event, use this code:

CboBox.Items.Add(CboBox.Text)<br />
TextBox1.Text = CboBox.Items.Count


This will add what is typed in the combobox to the combobox list, and then put the number of items in the list into the textbox.

Hope this helps.

Roy.

-- modified at 12:28 Thursday 8th December, 2005
GeneralRe: button doesn't work as expected Pin
mattlove8-Dec-05 7:19
mattlove8-Dec-05 7:19 
GeneralRe: button doesn't work as expected Pin
Roy Heil8-Dec-05 11:35
professionalRoy Heil8-Dec-05 11:35 
GeneralRe: button doesn't work as expected Pin
mattlove9-Dec-05 6:36
mattlove9-Dec-05 6:36 
Questioncrystal report Pin
farhha6-Dec-05 6:17
farhha6-Dec-05 6:17 
AnswerRe: crystal report Pin
abhinish6-Dec-05 17:53
abhinish6-Dec-05 17:53 
QuestionHow to set the text of a text box on a crystal report at run time? Pin
farhha6-Dec-05 5:53
farhha6-Dec-05 5:53 
QuestionCreate A Sound File (template) Pin
rderkis6-Dec-05 5:38
rderkis6-Dec-05 5:38 
AnswerRe: Create A Sound File (template) Pin
progload7-Dec-05 5:03
progload7-Dec-05 5:03 
AnswerRe: Create A Sound File (template) Pin
Gideon Engelberth7-Dec-05 5:52
Gideon Engelberth7-Dec-05 5:52 
QuestionPictureBox need bit of help Pin
cooler.CCCP6-Dec-05 4:33
cooler.CCCP6-Dec-05 4:33 
AnswerRe: PictureBox need bit of help Pin
SilverHorse6-Dec-05 11:53
SilverHorse6-Dec-05 11:53 
QuestionCannot see system tray icon Pin
matsnas6-Dec-05 2:45
matsnas6-Dec-05 2:45 
AnswerRe: Cannot see system tray icon Pin
Dave Kreskowiak6-Dec-05 6:48
mveDave Kreskowiak6-Dec-05 6:48 
GeneralRe: Cannot see system tray icon Pin
matsnas6-Dec-05 19:05
matsnas6-Dec-05 19:05 
GeneralRe: Cannot see system tray icon Pin
Dave Kreskowiak7-Dec-05 2:48
mveDave Kreskowiak7-Dec-05 2:48 
Questionvalidating dynamically generated text boxes Pin
pkorolev6-Dec-05 1:23
pkorolev6-Dec-05 1:23 
QuestionDetermine Line And Column Number For Notepad Pin
Samik Karmakar5-Dec-05 20:34
Samik Karmakar5-Dec-05 20:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.