Is it possible to bind datatable to the ToolStripMenuItem?
-
27-10-2019 - |
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.
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