Alright. So I'm fairly new to C#. What i've down thus far is create the beginnings of my program:

            using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
public partial class BirdNumber : Form
{
public BirdNumber()
{
InitializeComponent();
}

    private void BirdNumber_TextChanged(object sender, EventArgs e)
    {


    }

    private void SessionNumber_TextChanged(object sender, EventArgs e)
    {


    }

    private void dateTimePicker_ValueChanged(object sender, EventArgs e)
    {

    }

    private void Habituation_CheckedChanged(object sender, EventArgs e)
    {

    }

    private void Autoshaping_CheckedChanged(object sender, EventArgs e)
    {

    }

    private void TITraining_CheckedChanged(object sender, EventArgs e)
    {

    }

    private void TITesting_CheckedChanged(object sender, EventArgs e)
    {

    }

    private void StartButton_Click(object sender, EventArgs e)
    {



}


}

}

What I want to do is have the StartButton, when clicked is record which radiobutton was clicked as well as data from the 3 text boxes into a textfile.

I've googled many possible answers, but none of them seem to do all that I want. Any suggests?

I can provide more code if necessary, but it would just be the form.designer.cs code.

`

Dani AI

Generated

As suggested, break the task into three steps: determine which RadioButton is checked, read the TextBoxes/DateTimePicker, then append the data to a file. already has the handler stubs in place — the example below implements those steps, adds simple validation, writes a CSV line (with a header the first time), and reports success/failure. Replace NotesTextBox with the actual name of the third TextBox on the form and confirm the control names match your designer.

private void StartButton_Click(object sender, EventArgs e)
{
    if (string.IsNullOrWhiteSpace(BirdNumber.Text) || string.IsNullOrWhiteSpace(SessionNumber.Text))
    {
        MessageBox.Show("Please enter bird number and session number.", "Missing data",
            MessageBoxButtons.OK, MessageBoxIcon.Warning);
        return;
    }

    string trialType = "Unknown";
    if (Habituation.Checked) trialType = "Habituation";
    else if (Autoshaping.Checked) trialType = "Autoshaping";
    else if (TITraining.Checked) trialType = "TITraining";
    else if (TITesting.Checked) trialType = "TITesting";

    string dateTime = dateTimePicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
    string bird = BirdNumber.Text.Trim().Replace(",", " ");
    string session = SessionNumber.Text.Trim().Replace(",", " ");
    string notes = NotesTextBox.Text.Trim().Replace(",", " "); // replace with your third textbox name

    string line = string.Format("{0},{1},{2},{3},{4}", dateTime, bird, session, trialType, notes);
    string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "bird_log.csv");

    try
    {
        bool writeHeader = !File.Exists(path);
        using (var sw = new StreamWriter(path, true, Encoding.UTF8))
        {
            if (writeHeader) sw.WriteLine("DateTime,Bird,Session,TrialType,Notes");
            sw.WriteLine(line);
        }
        MessageBox.Show("Saved to " + path, "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    catch (Exception ex)
    {
        MessageBox.Show("Could not save file: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

Notes and troubleshooting: verify the StartButton.Click event is wired to StartButton_Click in the designer (or with StartButton.Click += StartButton_Click;). Keep radio buttons grouped so only one can be checked at a time (same container or GroupBox). Use Environment.GetFolderPath to avoid hard-coded paths and check file permissions if saving fails. For robust CSV handling (commas/quotes/newlines in fields) consider using a CSV library or quoting fields instead of the simple Replace shown here.

But what you will find when you Google are answers that handle part of what you are trying to achieve. Break it down into the steps:
Determine which radio button is clicked
read data from a control (your textbooks)
write to file

Each of these things can easily be googled and then put together to give you your complete answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.