Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagridview Strange Behavior

Status
Not open for further replies.

apex1x

IS-IT--Management
Aug 14, 2002
396
0
0
US
Whenever I try to have code execute during the selectedindexchanged event of my combobox on the datagridview cell, the cell refuses to update itself or the related objects properly.

I have a feeling the issue surrounds the endedit, beginedit, acceptchanges, and those other properties, however I have not come across much useful information about using them in a practical sense. I'm also not sure on the exact ordering/protocol for using them, assuming they may be a cause for these problems.

Anyways, here is some code that I'm referring to:

Notice the call to "costsntax", which executes fine if I click a button calling that sub, but when used in the selectedindexchanged event, does not perform correctly.

Ideas?

Code:
Public Sub dataGridView3_EditingControlShowing(ByVal sender As Object, _
       ByVal e As DataGridViewEditingControlShowingEventArgs) _
        Handles DataGridView3.EditingControlShowing

If DataGridView3.CurrentRow.Cells(1).Selected Then
            Dim comboBoxtemp3 As New ComboBox
            comboBoxtemp3 = CType(e.Control, ComboBox)
            If (comboBoxtemp3 IsNot Nothing) Then
                RemoveHandler comboBoxtemp3.SelectedIndexChanged, New EventHandler(AddressOf ComboBox3_SelectedIndexChanged)
                AddHandler comboBoxtemp3.SelectedIndexChanged, New EventHandler(AddressOf ComboBox3_SelectedIndexChanged)
             End If
        End If
    End Sub

    Public Sub ComboBox3_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
                               
    costsntax()

    End Sub
 
Does anyone have any suggestions/resources on dealing with this? Thanks.
 


Just a shot in the dark... but I often have control updating issues when I fail to have a line like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.LoadPage()
End if
End Sub

*** Someone verify this for me but what I think the above code does is NOT run my Code in the subroutine LoadPage if the Page is Posting back to itself. Maybe you have similar code that is resetting your controls and your not seeing the results you want.

Let me know if this helped, apologies if I was way off base.

~ Humour
 
OK, thanks for the tip. I'm not sure if thats the issue I'm having though, where the control is already loaded but there isn't something firing properly when it comes to code (such as various textbox calculations) in the control's change events. Once I leave the control, and run the code (such as a from a button), the code works fine.

Must be something simple here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top