Question database application with datagridview and binding navigator

tonifirnandes

Member
Joined
Mar 7, 2013
Messages
20
Programming Experience
1-3
Hello ALL the best programmer,

before go to my question today, let me introduce my self : my name is toni firnandes from batam indonesia. Nice to get you all in this forum and hopely you would like to help me solve my problem.

I have problem to make application database using sql server databse and visual basic .net. and the application just consist of datagridview and binding navigator. and i've never use that before.

Please anybody tell me how to do everything database operation such as INSERT, DELETE, EDIT, SELECT, and etc just using binding navigator and datagridview.

Thanks for attention,.

best regards,


toni firnandes.
 
well, thank you very much dear ian .
i have tried your suggestion and well everything is work okay. and then would you like to tell me how to do add, delete , edit and search operation databse using bindingnavigator button and the data edit from datagridview.

thanks best regards,


toni firnandes
 
Hi,

Are you sure you watched the whole tutorial since it answers the majority of what you have just asked. The only thing that the BindingNavigator does not give you is a Search facility which you need to create yourself based on what you are trying to do.

To start with Searching, have a look on the net for Filtering a BindingSource with VB.NET. Try this one:-

Part 3 of 5: Using BindingSource to navigate the Dataset with C# - YouTube

Cheers,

Ian
 
Hello dear Ian,


i've tried the video tutorial and that was so amazing, i don't need to do anything (make a code) for do insert , delete and even save "update all of my table database". i would likte to say thank you very much dear ian.

best regards,


toni firnandes.
 
Hello dear programmer,

after i follow the ian instruction and from the video above, finally i can make a simple aplication that can show my data table of my database and do add new record, delete record and save the data.

but i have problems again, would you like to help me again please.

i need make a application that if i havenot clicked a button (like Edit) i can edit data of my table in datagridview. and if i have clicked that button then i can edit the data. for this i have done, i just use datagridview.readonly = true to make the edit unable and change value to false to make the edit able.

and i put the code of datagridview.readonly = false to button add new of bindingnavigator so when i clicked the button i can edit the datatable to input new data. but if i put the code, i can edit the entire data of the table how can i just do insert new data but cannot edit the other data.


thanks, best regards,


toni firnandes.
 
Hi,

You CANNOT have a button to allow users to only add new records, without editing existing records, since to enter new records you need to have two things enabled, being, AllowUserToAddRows = True and ReadOnly = False.

The problem is, if this was coded in a button, as soon as you said ReadOnly = False then all the existing records would also become editable.

The way to achieve this would be to leave AllowUserToAddRows = True and then code the DataGridView.RowEnter Event to test if you were on a New row of the DataGridView and then set the ReadOnly = False to allow the user to enter the new row. If you then moved off the new row then this would be set back to ReadOnly = True to ensure that existing rows could not be edited. Have a look at this example:-

VB.NET:
Private Sub CustomersDataGridView_RowEnter(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles CustomersDataGridView.RowEnter
  If CustomersDataGridView.Rows(e.RowIndex).IsNewRow Then
    CustomersDataGridView.ReadOnly = False
  Else
    CustomersDataGridView.ReadOnly = True
  End If
End Sub

The only issue with this is that I get the feeling this may be a little beyond your education at the moment. If so, then you need to study up on how to use Events in VB.NET. Start here with chapter Eleven of this tutorial:-

Microsoft Visual Basic .NET tutorials for Beginners

Hope that helps.

Cheers,

Ian
 

Latest posts

Back
Top