How to show title in multi-column combobox ,and I to refresh it whan I save new record?

Kerry Ou 226 Reputation points
2023-03-24T03:08:57.5766667+00:00

https://www.codeproject.com/Articles/19781/A-data-bound-multi-column-combobox

I used this example for my Combobox( com_Plan),How to add column name on it ?

tempsnip

捕获

And then when I save new record how to refresh it ?

I try to call form load, but it is distorted.


 private void Form1_Load(object sender, EventArgs e)
        {
            Get_PlanNo(e,e);
           
        }

        private void Get_PlanNo(object sender, EventArgs e)
        {
            string sql = string.Format("SELECT   Plan_No, Footage, Pcs ,RecID FROM [VG1] WHERE   (LEFT(Plan_No, 1) = 'T')ORDER BY RecID DESC; ");
          
            com_plan.SelectedIndexChanged -= com_plan_SelectedIndexChanged;
            com_plan.DataSource = db.GetDataSet(sql).Tables[0];
            com_plan.DisplayMember = "Plan_No";
            com_plan.ValueMember = "Plan_No";
            com_plan.Text = "";
            com_plan.SelectedIndexChanged += com_plan_SelectedIndexChanged;

}

tempsnip1

Please help, thank you so much.

Developer technologies | Windows Forms
SQL Server | Other
Developer technologies | C#
{count} votes

Accepted answer
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2023-03-24T12:21:51.9733333+00:00

    I've not seen a clean control for this other than in third party libraries. The best I've seen has some issues from Code Project e.g. does not properly size columns and needed some tweaks.

    screenshot

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.