Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 138249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:14:03+00:00 2026-05-11T07:14:03+00:00

I have a DGV in VB.Net 2008 connected to an Access DB table. The

  • 0

I have a DGV in VB.Net 2008 connected to an Access DB table. The DGV is not Read Only, but is full of read-only columns except for one, which contains a combo box. The combo box allows the user to select an outcome for that particular row, and then the program copies in a pre calculated value into the ‘Profit’ column depending upon the item selected in the combobox. Then the user hits the Save button and the DB updates (currently via SQL methods in the XSD).

Easy enough so far.

Here is the code.

Private Sub DGUserBets_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DGUserBets.EditingControlShowing      Dim combo As ComboBox = CType(e.Control, ComboBox)      If (combo IsNot Nothing) Then           // Remove an existing event-handler, if present, to avoid           // adding multiple handlers when the editing control is reused.         RemoveHandler combo.SelectedIndexChanged, _             New EventHandler(AddressOf DGUBStake_SelectedIndexChanged)          // Add the event handler.          AddHandler combo.SelectedIndexChanged, _             New EventHandler(AddressOf DGUBStake_SelectedIndexChanged)      End If  End Sub   Private Sub DGUBStake_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)      Dim myStatus As ComboBox = CType(sender, ComboBox)      Dim row = DGUserBets.CurrentRow      Select Case myStatus.SelectedIndex         Case 0             row.Cells('DGUBProfit').Value = 0             // pending. no action         Case 1             row.Cells('DGUBProfit').Value = row.Cells('DGUBIfWin').Value             // win         Case 2             // loses             row.Cells('DGUBProfit').Value = row.Cells('DGUBIfLose').Value         Case 3             // void             row.Cells('DGUBProfit').Value = 0     End Select   End Sub 

The problem I have is that it would seem that if a user selects the desired outcome from the combobox but does NOT hit Enter, and simply mouses on to a different combobox to again select the outcome for a different row, the first eventhandler is not disconnected and thus the events fire multiple times. This then causes various default MsgBox errors and brings up problems when the user tries to commit all changes to the DB/exit program etc etc.

What do I need to do? Do I need to .EndEdit somewhere appropriate to force the row to save the changes? And where should I call this?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:14:04+00:00Added an answer on May 11, 2026 at 7:14 am

    A quick glance at the code brings up this question: If you create a new EventHandler when removing the existing one is it the same one?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a read only DGV on a tab of my application. I let
I have a DGV with columns code and name. Depends of lenght of a
net webdeveloper and usually don't make any win32 apps. but now i have to.
I have one DataGridView named dgv . dgv is pretty much a plain gridview.
I have a datagridview bound to a datatable. One of the columns in the
I finally solved one problem but now i have another. I found out how
I have a databound dgv that contains combobox columns. When the user selects an
I have a non databound DGV (no datasource, etc; rows added manually). To filter
I have a datable myTable, which is bind with a DataGridView dgv. The DataGridView
Have deployed numerous report parts which reference the same view however one of them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.