Click here to Skip to main content
15,391,989 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to display table column data as lists with radio button.

first record only display in radio button lists and remaining does not come .
but i have 13 records in my table.
first record also does not printed fully, first word only printing here

first record is "Particulate Matter (PM 2.5)" but the code prints only "Particulate"

What I have tried:

private void btnLoad_Click(object sender, EventArgs e)
            DataSet ds = new DataSet();
            objBO.QueryType = SQLQuery.ToString();
            ds = objBAL.GetSearch(objBO);
            int val = ds.Tables[0].Rows.Count;
            MessageBox.Show("val is :"+val);
            if (ds.Tables[0].Rows.Count != 0)
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    RadioButton RB = new RadioButton();
                    RB.Text = ds.Tables[0].Rows[i]["TestParameters"].ToString();
                    //RB.GroupName = "Database";
                    SampleListBox.DisplayMember = "TestParameters";

                //pnlReport.Visible = false;
                lblMsg.Text = "No records found...";
Updated 12-Jun-22 8:47am

1 solution

Maybe you can set the ListBox.Width property and RadioButton size to a greater value.
Or use this auto-resize C# Listbox (updated)[^]

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