Question

I'm using ContextMenuStrip & i created the submenus under ContextMenuStrip at runtime. By adding object of ToolStripMenuItem class. I'm having one datatable from that table i want to populate my submenus by using id & name field from my datatable for my further processing of application.

Is it possible?

thanks.

Was it helpful?

Solution

Try something like this:

foreach (DataRow dr in dataTable.Rows) {
                cms.Items.Add(new ToolStripMenuItem() {
                    Text = dr["Name"].ToString()
                });
            }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top