0

I am adding the "Procs" class as a List item:

public static List<Procs> allprocs = new List<Procs>();

So when a user fills out a form and clicks "Add Proceedure":

private void btAddProcedure_Click(object sender, EventArgs e)
{
    ClaimVars.allprocs.Add(new Procs
    {

        TreatmentBusinessID = Convert.ToInt32(proLocID.Text),
        DiagCodeID = ClaimVars.DiagID,
        CPTCodeID = ClaimVars.CPTID,
        Charges = Convert.ToDouble(txtCharges.Text),
        AmountPaid = Convert.ToDouble(txtPaid.Text),
        DateServicedFrom = Convert.ToDateTime(dateTimePicker1.Text),
        DateServicedToo = Convert.ToDateTime(dateTimePicker2.Text),
        Notes = notesDiagServ.Text
    });

    // Change the DataSource.
    listBox1.DataSource = null;
    listBox1.DataSource = ClaimVars.allprocs;
    }
}

They will see a new list item.

How do I display the values of this class rather than adding the name of the object?

After adding a proceedures, this is how my listbox looks:

Project_LB223.ClaimForms.Procs
Project_LB223.ClaimForms.Procs
Project_LB223.ClaimForms.Procs
Project_LB223.ClaimForms.Procs

This is how I would like it to look:

1     32     44     33.44     22.17     12/17/09 11:21:52     12/22/09 10:31:64     patient was feeling sick.
2     42     72     12.45     10.67     12/18/09 22:51:22     12/23/09 11:21:25     patient was showing signs of fatigue and shortness of breath.
1     68     57     83.64     55.47     12/19/09 23:25:45     12/24/09 15:38:42     the patient is feeling better.
5     12     22     37.44     23.45     12/22/09 16:81:11     12/25/09 19:35:22     the patient does not have any more symptoms.

4 Answers 4

1

You can, for example, add ToString() method override, like this:

public class Procs
{
    public override string ToString()
    {
       string spaceinbetween = new string(' ', 5);
       return TreatmentBusinessID + spaceinbetween + DiagCodeID + spaceinbetween ...
    }
}

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

1

Your data is displayed with a call to ToString(). You can override this method in your class to display the data however you like.

Comments

1

You can achieve a colum layout by using either

  • override ToString() on the Procs class
  • use the Format event of the listbox.

In both case you'll need to set a fixed-width font, so using a DataGrid or ListView might be better.

Comments

0

A ListBox can't display multiple columns, use a DataGridView instead.

3 Comments

I understand, datagrid is not an option. Even building a string with tabs inbetween values is acceptable.
Why is it not an option? Doing this with a ListBox will be ugly and very uncomfortable for the user...
The project was originally using GridView's im actually being paid to take them out haha.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.