473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

HLP: GRRR... StartUp Troubles

GRRRR... I've run across a situation in which I have NO solution. Hopefully
there is one. VB.net.

It's rather simple.

I've a ComboBox that get's populated via a Database. And I pre-select (during
Formload) the Index using SelectedIndex:

' Get User info from Data Base fill
daPickUser.Fill(dsPickUser.MASTER_PRM_EMPLOYEE)
cmbUserName.SelectedIndex = cmbUserName.FindStringExact(strUserID)

Now the above works just fine. It finds my strUserID (ie: FEU001 which is
Index #28) and that is what is listed in the ComboBox on startup. Great!

However, I want to use the Combobox to select another User at some time. When
I ENABLE the following Private Sub for the Combobox, I get my troubles...

My Combobox even is thus...

Private Sub cmbUserName_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbUserName.SelectedIndexChanged

dsTimberline.tblTimeEntry.Clear()
' Refresh the Data Grid with New User Selected
strUserID = cmbUserName.Text
daTimberline.SelectCommand.Parameters(0).Value = strUserID
daTimberline.Fill(dsTimberline.tblTimeEntry)

End Sub
What happens is that on startup, somehow the Combobox SelectedIndexChanged
sets my Combobox Index to Zero (0)... every time. I don't want Index of 0.
But the listing of what is the Index number of my strUserID.

How can I prevent the cmbUserName_SelectedIndexChanged from being triggered
during startup???

Regards,

Bruce
Jul 21 '05 #1
3 1420
On 2003-10-23, Mr B <No*****@address.not> wrote:
GRRRR... I've run across a situation in which I have NO solution. Hopefully
there is one. VB.net.

It's rather simple.

I've a ComboBox that get's populated via a Database. And I pre-select (during
Formload) the Index using SelectedIndex:

' Get User info from Data Base fill
daPickUser.Fill(dsPickUser.MASTER_PRM_EMPLOYEE)
cmbUserName.SelectedIndex = cmbUserName.FindStringExact(strUserID)

Now the above works just fine. It finds my strUserID (ie: FEU001 which is
Index #28) and that is what is listed in the ComboBox on startup. Great!

However, I want to use the Combobox to select another User at some time. When
I ENABLE the following Private Sub for the Combobox, I get my troubles...

My Combobox even is thus...

Private Sub cmbUserName_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbUserName.SelectedIndexChanged

dsTimberline.tblTimeEntry.Clear()
' Refresh the Data Grid with New User Selected
strUserID = cmbUserName.Text
daTimberline.SelectCommand.Parameters(0).Value = strUserID
daTimberline.Fill(dsTimberline.tblTimeEntry)

End Sub
What happens is that on startup, somehow the Combobox SelectedIndexChanged
sets my Combobox Index to Zero (0)... every time. I don't want Index of 0.
But the listing of what is the Index number of my strUserID.

How can I prevent the cmbUserName_SelectedIndexChanged from being triggered
during startup???

Regards,

Bruce


Bruce...

A possilbe solution to this is to remove the handles clause from your
event handler. Then AFTER you fill the combobox, you can associate the
event with the combobox using AddHandler:

Private Sub Form_Load(...) Handles...

' Fill Your Combo Box

' Add your handler dynamcially
AddHandler cmbUserName.SelectedIndexChanged, AddressOf
cmbUserName_SelectedIndexChanged
End Sub
' then change the sig of the event to:
Private Sub cmbUserName_SelectedIndexChanged( _
ByVal sender As System.Object, ByVal e As System.EventArgs)

'Do Cool Stuff!
End Sub

HTH
--
Tom Shelton
MVP [Visual Basic]
Jul 21 '05 #2
With Deft Fingers, Tom Shelton <to*@mtogden.com> wrote:
On 2003-10-23, Mr B <No*****@address.not> wrote:
GRRRR... I've run across a situation in which I have NO solution. Hopefully
there is one. VB.net.

A possilbe solution to this is to remove the handles clause from your
event handler. Then AFTER you fill the combobox, you can associate the
event with the combobox using AddHandler:


Thanks Tom... I'll try that!

Regards,

Bruce
Jul 21 '05 #3
With Deft Fingers, Tom Shelton <to*@mtogden.com> wrote:
A possilbe solution to this is to remove the handles clause from your
event handler. Then AFTER you fill the combobox, you can associate the
event with the combobox using AddHandler:


Sweet!!! Worked GREAT! Many Thanks!

Bruce
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mr. B | last post by:
GRRRR... I've run across a situation in which I have NO solution. Hopefully there is one. VB.net. It's rather simple. I've a ComboBox that get's populated via a Database. And I pre-select...
3
by: Mr. B | last post by:
GRRRR... I've run across a situation in which I have NO solution. Hopefully there is one. VB.net. It's rather simple. I've a ComboBox that get's populated via a Database. And I pre-select...
0
by: Madmax | last post by:
I am trying to use the .hlp file (an old help from for an existing app) in my application .Although the file shows up but it does not open the desired search string this is what I am doing ...
2
by: HornyAZNBoy | last post by:
I've just wrote a hlp file to a program I just completed. Now I want to open that hlp file with a command on my program. I've tried using the Call Shell(C:/WINDOWS/Cris/desktop/MS Skill Book/Skill...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.