473,322 Members | 1,405 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,322 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 1416
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.