none
I need to make a formulary and I don't know how to start RRS feed

  • Question

  • I'm a student and I need help making a simple formulary. I really aprecciate if anyone could waste a bit of their time to explain to me the basics as I need to get this working ASAP. 

    Bascially, a formulary where you create new pacients and then list them in a DataGridView. I am having trouble programming the buttons to create a new object and the information of the objects in my list. 

    Thanks.

    Tuesday, March 17, 2020 2:40 PM

All replies

  • You will need to supply more details.

    Where does the data come from e.g. user input , database table, text file etc ?

    How do you expect to have data placed into a DataGridView, from setting the DataSource to a list or a DataTable?

    And add more details where get you help quicker rather than less details.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, March 17, 2020 3:29 PM
    Moderator
  • Hi JoãoSilva123,

    Thank you for posting here.

    I guess you want to enter the information of the new object in the textbox and then insert it into the datagridview after clicking the button, right?

    If my guess is correct, you can refer to the following code to achieve this function.

        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            DataTable dataTable = new DataTable();
            private void button1_Click(object sender, EventArgs e)
            {
                string firstColumn = textBox1.Text;
                string secondColumn = textBox2.Text;
    
                string[] row = { firstColumn, secondColumn };
                dataTable.Rows.Add(row);
            }
          
            private void Form1_Load(object sender, EventArgs e)
            {
              
                dataTable.Columns.Add("ID",typeof(string));
                dataTable.Columns.Add("Name",typeof(string));
                dataTable.Rows.Add("1","Test1");
                dataTable.Rows.Add("2","Test2");
                dataGridView1.DataSource = dataTable;
            }
        }

    If it is wrong, please describe your requirements in detail so that we can better understand your problem.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 18, 2020 7:46 AM