Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My questions:
1. There is a button, a textbox and a datagridview on the form.
When the button is clicked, the id, name, surname and salary of the personnel belonging to the company written in the textbox1
It is requested to transfer the information to datagridview1.
Using object-oriented programming techniques the required class (with methods) and from that class
I need to encode the object to be created.

2. I need to send a message on the screen of the total salary of all the personnel transferred to the datagirdview1 of the question I wrote above, I would be glad if you could help me. Thank you from now

What I have tried:

I can not :/ ı am a beginner
Posted
Updated 22-Jun-21 20:26pm
v2

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
As to the question #1:
Think of it! You can NOT get: {id, name, surname and salary of the personnel} from one textbox. You need at least 4 textboxes.
You need to create a class[^] with all those properties (members). Note, that salary have to be a numeric value and it can not be an integer! As a textbox stores text, you have to convert that text into numeric value...
Then a collection (list)[^] of your class.
Inside button's click method you have to:
- create an instance of your class,
- set all members (based on values stored in the textboxes),
- add that instance of your class on the list,
- bind that list to DataGridView.DataSource[^]

As to the question #2:
You need to loop through the list (of your custom class) and sum up salaries.

That'a all!

For further details, please see: Bind data to DataGridView Control - Windows Forms .NET Framework | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900