ashish kumar

ashish kumar

  • NA
  • 4
  • 836

Working with listbox in C#

Mar 14 2015 3:17 AM
Dear users, I am new to C#. I have a project on pathology where i have been asked to add diagnostics tests programatically into somewhere (like listbox, datagridview or Listview) & based on the test choosed I need to print it on A4 paper (the A4 paper has header & footer added already on page). I have added text boxes, drop-down menus to my form ( I choosed listbox1).  The problem is that when I add "Doctor name" & "Patient name" in a single line in listbox, the patient name shifts at extreme corner (if doctor name is long enough) & does not remain at the position where I ask it to sit. Hence I googled it  to find if we can insert text in listbox using X or Y coordinates but no to avail. I am frustated now. I also tried to use other controls like datagridview or Listview but they need to get specific columns names which does not meet my project requirements. Please help me.  The sample code is as below.
 
 
private void btn_patient_add_Click(object sender, EventArgs e)
{
listBox1.Items.Add(lbl_patient_name.Text + " " + comboBox1.Text + " " + txtbox_patient.Text + "                                                                                " + lbl_age.Text+" "+cbox_age.Text+"/"+cbox_sex.Text);
listBox1.Items.Add("\n");
listBox1.Items.Add(lbl_ref.Text+" "+cbox_ref.Text+ " "+txtbox_date.Text);
listBox1.Items.Add("\n");
listBox1.Items.Add("__________________________________________________________________________________________________");
//listBox1.Items.Insert(10, "First");
}

Answers (3)