Click here to Skip to main content
16,006,594 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to make an ad blocker for web browser? Pin
Chaim Tovim13-Nov-13 1:22
Chaim Tovim13-Nov-13 1:22 
QuestionProblem regarding datagrid viewbutton column Pin
Member 1019283531-Oct-13 0:54
Member 1019283531-Oct-13 0:54 
QuestionRe: Problem regarding datagrid viewbutton column Pin
Eddy Vluggen31-Oct-13 8:15
professionalEddy Vluggen31-Oct-13 8:15 
Questioneror ,operator' = 'is not defined for system.windows.forms.datagridviewcolumn and system.windows.forms.datagridviewbuttoncolumn Pin
Member 1019283530-Oct-13 1:22
Member 1019283530-Oct-13 1:22 
AnswerRe: eror ,operator' = 'is not defined for system.windows.forms.datagridviewcolumn and system.windows.forms.datagridviewbuttoncolumn Pin
Richard MacCutchan30-Oct-13 2:04
mveRichard MacCutchan30-Oct-13 2:04 
GeneralRe: eror ,operator' = 'is not defined for system.windows.forms.datagridviewcolumn and system.windows.forms.datagridviewbuttoncolumn Pin
Member 1019283530-Oct-13 20:41
Member 1019283530-Oct-13 20:41 
SuggestionRe: eror ,operator' = 'is not defined for system.windows.forms.datagridviewcolumn and system.windows.forms.datagridviewbuttoncolumn Pin
Richard MacCutchan30-Oct-13 22:00
mveRichard MacCutchan30-Oct-13 22:00 
AnswerRe: eror ,operator' = 'is not defined for system.windows.forms.datagridviewcolumn and system.windows.forms.datagridviewbuttoncolumn Pin
TnTinMn31-Oct-13 9:27
TnTinMn31-Oct-13 9:27 
Quote:
I m getting error that Operator '=' is not defined for types 'System.Windows.Forms.DataGridViewColumn' and 'System.Windows.Forms.DataGridViewButtonColumn'

First off, assuming that editbutton and delbutton are assigned to the proper columns in the dgvLorryMaster.Columns collection, there is no need to try and compare the columns. The Column.Index property is all that is needed.

Please never write code like this:
Quote:
Dim currentrow As Integer = Integer.Parse(e.RowIndex.ToString())

"e.RowIndex" is an integer to start with.

I have attempted to restructured your code to make it easier to understand and eliminate the errors as follows. Hopefully this will help.
VB
Private Sub dgvLorryMaster_CellContentClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvLorryMaster.CellContentClick
   ' e.Rowindex can = -1 if column header is clicked, 
   If e.RowIndex > -1 AndAlso (e.ColumnIndex = editbutton.Index OrElse e.ColumnIndex = delbutton.Index) Then
      Try
         Dim id As Int32
         ' extract the id value
         ' if the dgv is bound to a datatable, it could have dbnull for a cell value
         If dgvLorryMaster(2, e.RowIndex).Value IsNot DBNull.Value Then
            If dgvLorryMaster(2, e.RowIndex).ValueType Is GetType(Int32) Then
               id = DirectCast(dgvLorryMaster(2, e.RowIndex).Value, Int32)
            Else
               If Not Int32.TryParse(dgvLorryMaster(2, e.RowIndex).Value.ToString(), id) Then
                  Throw New InvalidCastException("can not extract ID")
               End If
            End If
         End If

         Select Case e.ColumnIndex
            Case editbutton.Index
               Displaylorry(id)
               'Dim datadeletelorry As New DataSet() ' **** what is this for ????

            Case delbutton.Index
               Dim num As DialogResult = MessageBox.Show("Are you want to delete the record !!!.", "", MessageBoxButtons.YesNo)
               If num = DialogResult.Yes Then
                  If lbll.deletelorry(id) Then
                     Cleartext()
                     MessageBox.Show("Deleted Successfully")
                     bindgrid()
                  End If
               Else
                  Cleartext()
               End If
         End Select
      Catch ex As Exception
         MessageBox.Show(ex.Message)
      End Try
   End If
End Sub

GeneralRe: eror ,operator' = 'is not defined for system.windows.forms.datagridviewcolumn and system.windows.forms.datagridviewbuttoncolumn Pin
Member 101928351-Nov-13 21:11
Member 101928351-Nov-13 21:11 
Questionproblem not solved Pin
coolerfantasy29-Oct-13 19:31
coolerfantasy29-Oct-13 19:31 
AnswerRe: problem not solved Pin
Richard MacCutchan30-Oct-13 2:07
mveRichard MacCutchan30-Oct-13 2:07 
AnswerRe: problem not solved Pin
Dave Kreskowiak30-Oct-13 2:32
mveDave Kreskowiak30-Oct-13 2:32 
AnswerRe: problem not solved Pin
Vaclav_3-Nov-13 14:36
Vaclav_3-Nov-13 14:36 
QuestionCheckPIDDll Pin
Member 1027776329-Oct-13 9:34
Member 1027776329-Oct-13 9:34 
AnswerRe: CheckPIDDll Pin
Dave Kreskowiak29-Oct-13 10:27
mveDave Kreskowiak29-Oct-13 10:27 
QuestionProblem in opening forms Pin
SPSandy27-Oct-13 7:43
SPSandy27-Oct-13 7:43 
AnswerRe: Problem in opening forms Pin
Dave Kreskowiak27-Oct-13 10:20
mveDave Kreskowiak27-Oct-13 10:20 
AnswerRe: Problem in opening forms Pin
Chaim Tovim13-Nov-13 1:24
Chaim Tovim13-Nov-13 1:24 
QuestionLAN Port Controlling Relay Pin
coolerfantasy26-Oct-13 21:45
coolerfantasy26-Oct-13 21:45 
AnswerRe: LAN Port Controlling Relay Pin
Jonathan Davies27-Oct-13 2:13
Jonathan Davies27-Oct-13 2:13 
AnswerRe: LAN Port Controlling Relay Pin
Dave Kreskowiak27-Oct-13 5:31
mveDave Kreskowiak27-Oct-13 5:31 
AnswerRe: LAN Port Controlling Relay Pin
coolerfantasy27-Oct-13 19:37
coolerfantasy27-Oct-13 19:37 
GeneralRe: LAN Port Controlling Relay Pin
Richard MacCutchan27-Oct-13 22:52
mveRichard MacCutchan27-Oct-13 22:52 
GeneralRe: LAN Port Controlling Relay Pin
Dave Kreskowiak28-Oct-13 1:40
mveDave Kreskowiak28-Oct-13 1:40 
GeneralRe: LAN Port Controlling Relay Pin
coolerfantasy28-Oct-13 19:51
coolerfantasy28-Oct-13 19:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.