Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to manually display Header like "--Select--" as first row then Column header like ID | Value in Combobox winformC#

$
0
0

HI,

I am trying to find a solution my issue for long and no help online.

I have a combobox ,  Datasource is a datatable with  value like  StudyID as value and i want to display two columns ( concatation of columns) as Display

I am able to do it with just one column no issue as below method shows. But how to dot with two columns? i need to show display as  "Something" and when selected i want value to be my studyID. and also i want column header and "-Select"

internal static void FillParticipantDropdown(ComboBox box)
        {

            ////////////Fill PPTID dropwron with exisiting PPTs IDs/////////////////////////////////////////////
            DataTable dt_PPTID = Utility.GetParticipantsIDs().Tables[0];
            box.Items.Clear();
            box.Items.Add("-Select-");
            foreach (DataRow dRow in dt_PPTID.Rows)
            {
                try
                {
                    box.Items.Add(dRow["PreScreenID"].ToString());
                }
                catch
                {

                }
            }
            box.SelectedIndex = 0;

        }


JRS


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>