Click to See Complete Forum and Search --> : menu problem
edwinMuthu
March 3rd, 2006, 09:19 AM
menuitem1.Text = "Master"
menuitem2.Text = "Sub Master"
While reader.Read
menuitem(j) = New MenuItem
menuitem(j).Text = reader("vcMenuName")
menuitem(j).MenuItems.Add(reader("vcMenuName"))
j = j + 1
End While
Dim k As Integer
mainmenu1.MenuItems.Add(menuitem1)
Me.Menu = mainmenu1
End Sub
This was my code my code is running but iam using single query to get the menu dynamically , Here is my problem starts
the menu come straight Ex(Ajeeth,Anand,Charkes,muthu,hari)
here i need anand as sub menu under anand, i needed charkes,muthu, hari
so this is result i need
Thanks in advance
aniskhan
March 5th, 2006, 01:57 PM
these codes may help u to understand howto add menus dynamically
code (http://www.codeproject.com/vb/net/databasemenu.asp)
code (http://www.dotnetspider.com/kb/Article1636.aspx)
edwinMuthu
March 6th, 2006, 01:58 AM
Hi Thanks u veryMuch,
It is working nice, My another problems is i have said that i taking the name from database and loading the menu and giving the addhandler for click event.
While k <= j - 1
menuitem1.MenuItems.Add(menuitem(k))
AddHandler menuitem(k).Click, menuitems_click
k = k + 1
End While
Here i have code for each name so when click this name the code should be retrived For example
i have muthu in the menulist and and have 02 as code in database so when im clicking the muthu i needed this 02 at EventHandler menuitems_Click
how can i pass this code to the handler.
Thanks in Advance
aniskhan
March 6th, 2006, 05:56 AM
to add event handler write like this
AddHandler menuitem(k).Click,AddressOf menuitems_click
edwinMuthu
March 6th, 2006, 06:50 AM
Thanks For u Reply,
I have done this already, but this is not my problem
See i have two fields in database Name and ID.
Iam taking the name and id through reader. Iam retriving the id in formload
so i want to pass this id to the EvenHandler,What can u do
Thanks in advance
aniskhan
March 6th, 2006, 10:28 PM
i hope this may give u ideas
' Declare an event.
Public Event SE(ByVal id As Integer)
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim id As Integer = 20
AddHandler SE, AddressOf EHandler
RaiseEvent SE(id)
'RemoveHandler SE, AddressOf EHandler
End Sub
Public Sub EHandler(ByVal Id As Integer)
'work on id
MessageBox.Show("Received ID " & CStr(Id))
End Sub
edwinMuthu
March 6th, 2006, 11:33 PM
Thank u Very Much anishKhan It is working well,
But i cannot get the data in a collections
See i have 12,13,14,15,16 these are the NameId In the DataBase
and Muthu,Hari,Vinoth,Charles,Sai these are the Name in the Database
I Got these Names in Menu Details when iam clicking the individual menu the respective Id wants to be retrieved. The code u gave was nice and it is working well but only the Last data 16 is coming for all the Names so that i cant able to get the previous id wants can i do,Pls help me
Thanks in Advance
aniskhan
March 7th, 2006, 01:39 AM
get the id on base of something u got about it .
when u click the menu u get the menu TEXT ,u can use it to get the id from the database.
through a query to the database
SELECT id FROM database WHERE Detail='MenuName'
edwinMuthu
March 7th, 2006, 04:29 AM
thanks u Very much
Finally i got the solutions by using hashtable
I have used the think which u have said, but that is not proper a manner
since we are taking the Name, NameId previously using a query. so we should not use another seperate query to take the same NameId
Thank u Very Much Aniskhan
aniskhan
March 7th, 2006, 02:03 PM
happy that u solved the problem..
using hashTable is also a solution.
we can also use the dataset having the previous query results in it, u can use these to get the id.
edwinMuthu
March 7th, 2006, 10:58 PM
hi anish using dataset is also working
Thank u very much
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.