473,466 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1421
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...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.