J
Jasim
hi everyone,
i have a problem with context menu's. actually what i'm
trying to do is to call the same function with the parent
item when clicked as well as sub items. it works for sub
menu item but fails for the parent menu item.
can someone please help me with this ....
thanx
-jasim
i'm attaching the code as well.
****************** Code ***********************
public void AddTAMenu()
{
try
{
DataSet ds = new DataSet();
ds.ReadXml("D:TA.xml");
DataTable dt1 = new DataTable();
dt1 = ds.Tables["TAClass"];
foreach (DataRow dr1 in
dt1.Rows)
{
string criteria;
criteria
= "TAClassID=" + dr1.ItemArray.GetValue(0).ToString();
MenuItem ClassItem
= new MenuItem(dr1.ItemArray.GetValue(1).ToString(),new
EventHandler(SelectValue));
foreach (DataRow
dr2 in
ds.Relations["class_generic"].ChildTable.Select(criteria))
{
ClassItem.MenuItems.Add(new MenuItem
(dr2.ItemArray.GetValue(2).ToString(),
new EventHandler(SelectValue)));
TANamepopUpMenu.MenuItems.Add
(dr2.ItemArray.GetValue(2).ToString(),new
EventHandler(SelectValue));
}
TAClasspopUpMenu.MenuItems.Add(ClassItem);
}
}
catch (Exception exp)
{
throw new Exception
("Search.AddTAMenu : " + exp.Message);
}
}
private void SelectValue(object sender, EventArgs e)
{
MenuItem miClicked = (MenuItem)
sender;
string item = miClicked.Text;
txtTA.Text =
miClicked.Text.ToString();
}
..
i have a problem with context menu's. actually what i'm
trying to do is to call the same function with the parent
item when clicked as well as sub items. it works for sub
menu item but fails for the parent menu item.
can someone please help me with this ....
thanx
-jasim
i'm attaching the code as well.
****************** Code ***********************
public void AddTAMenu()
{
try
{
DataSet ds = new DataSet();
ds.ReadXml("D:TA.xml");
DataTable dt1 = new DataTable();
dt1 = ds.Tables["TAClass"];
foreach (DataRow dr1 in
dt1.Rows)
{
string criteria;
criteria
= "TAClassID=" + dr1.ItemArray.GetValue(0).ToString();
MenuItem ClassItem
= new MenuItem(dr1.ItemArray.GetValue(1).ToString(),new
EventHandler(SelectValue));
foreach (DataRow
dr2 in
ds.Relations["class_generic"].ChildTable.Select(criteria))
{
ClassItem.MenuItems.Add(new MenuItem
(dr2.ItemArray.GetValue(2).ToString(),
new EventHandler(SelectValue)));
TANamepopUpMenu.MenuItems.Add
(dr2.ItemArray.GetValue(2).ToString(),new
EventHandler(SelectValue));
}
TAClasspopUpMenu.MenuItems.Add(ClassItem);
}
}
catch (Exception exp)
{
throw new Exception
("Search.AddTAMenu : " + exp.Message);
}
}
private void SelectValue(object sender, EventArgs e)
{
MenuItem miClicked = (MenuItem)
sender;
string item = miClicked.Text;
txtTA.Text =
miClicked.Text.ToString();
}
..