Hi guys!
I have a problem with my datagridview.
here goes:
1. I have a datagridview that displays borrower's information.
2. upon click on the leftside button of the row (fullrowselect) the controls are auto populated with data. (userid, library card no. etc..)
3.here is my datagridview cell click event code:
4. here is my select statement to populate the controls:Code:Private Sub grdBorrowers_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdBorrowers.CellClick With borrowers Try If borrowers.selectborrower(grdBorrowers.CurrentCell.Value) = True Then load_data() End If Exit Sub Catch Err As DataException MsgBox(MSG_ERR) End Try End With End Sub
4. the problem is when i click on a cell that is not an integer it creates an error.Code:Public Function selectborrower(ByVal mvuserid As Integer) As Boolean Try SqlExec = "" SqlExec = SqlExec & "select" & vbCr SqlExec = SqlExec & "userid," & vbCr SqlExec = SqlExec & "libcardno," & vbCr SqlExec = SqlExec & "borrowertype," & vbCr SqlExec = SqlExec & "empstudno," & vbCr SqlExec = SqlExec & "fname," & vbCr SqlExec = SqlExec & "mname," & vbCr SqlExec = SqlExec & "lname," & vbCr SqlExec = SqlExec & "address," & vbCr SqlExec = SqlExec & "birthdate," & vbCr SqlExec = SqlExec & "gender," & vbCr SqlExec = SqlExec & "contactno," & vbCr SqlExec = SqlExec & "picpath," & vbCr 'SqlExec = SqlExec & "referflag," & vbCr SqlExec = SqlExec & "remarks," & vbCr SqlExec = SqlExec & "regdate," & vbCr SqlExec = SqlExec & "endregdate," & vbCr SqlExec = SqlExec & "deleteflag" & vbCr SqlExec = SqlExec & "FROM borrowers" & vbCr SqlExec = SqlExec & "where userid =" & mvuserid & " " & vbCr SqlExec = SqlExec & "and DeleteFlag = 0" & " " & vbCr SqlCon.Open() SqlCmd = New SqlCommand(SqlExec, SqlCon) SqlDR = SqlCmd.ExecuteReader(CommandBehavior.CloseConnection) Do While SqlDR.Read userid = (SqlDR("userid")) libcardno = (SqlDR("libcardno")) borrowertype = (SqlDR("borrowertype")) empstudno = (SqlDR("empstudno")) fname = (SqlDR("fname")) mname = (SqlDR("mname")) lname = (SqlDR("lname")) address = (SqlDR("address")) birthdate = (SqlDR("birthdate")) gender = (SqlDR("gender")) contactno = (SqlDR("contactno")) picpath = (SqlDR("picpath")) 'referflag = (SqlDR("referflag")) remarks = (SqlDR("remarks")) regdate = (SqlDR("regdate")) endregdate = (SqlDR("endregdate")) deleteflag = (SqlDR("deleteflag")) Loop SqlDR.Close() SqlCon.Close() selectborrower = True Exit Function selectborrower = False SqlCon.Close() Catch err As SqlException MsgBox(err.Message) End Try End Function
5. my idea is to disable the cells inside the grid. only userid or the leftside button should be enabled. how can i do that? is that possible?
thanks in advance for the help! I really appreciate it! more power to the group!


Reply With Quote

