|
Good Morning everybody, I am awfully new to posting on the code project website, so please go gently with me.
I am trying to figure out how to add sub sub menues to a menu programatically. I have the menu set up as follows
File.......Options......Play
=================================
Open.......Prefs.......Play DVD
Exit
Now after the program runs, I wish to add a Sub Menu to PLAY DVD, how could i accomplish this?
hope everyone reading this understands what i am trying to accheive
|
|
|
|
|
you can give a name to the toolstripmenuitem (play dvd) (for further reference I'll name it DVD;P)
then you can simply add one like this
Dim mnuunderdvd As New ToolStripMenuItem("underDVD")
AddHandler mnuunderdvd.Click, AddressOf mnuunderdvd_Click
DVD.DropDownItems.add(mnuunderdvd)
in mnuunderdvd_click you put the code that needs to run when the user clicks it
hope this helps
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Thank you that's great, how do i implement the Handler to handle the click event of the newley created item.
Sorry for such ignorance, but I am quite nwe to VB.Net
|
|
|
|
|
the handler is a normal methode wich would look like this:
Private Sub mnuunderdvd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
TDDragon wrote: the handler is a normal methode wich would look like this:
Private Sub mnuunderdvd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Thank you. Another query if I may.
I suppose there is no way around adding Handlers programatically as this is what i will be requiring.
My Form1.Load event call a sub routine as follows
Load_Menus()
then my sub routine is as follows
Public sub Load_Menus()<br />
<br />
For Each drive As DriveInfo In My.Computer.FileSystem.Drives<br />
<br />
If drive.DriveType = DriveType.CDRom Then<br />
<br />
Dim PlayDvd As New ToolStripMenuItem<br />
PlayDvd.Text = drive.Name<br />
Me.dvdMenuItem.DropDownItems.Add(PlayDvd)<br />
<br />
else<br />
End If<br />
<br />
next<br />
end sub
so i want to loop through all available CD-Drives on the system and if it finds one then add it to the menu under DVD.
But if it was to find several cd drives, how would i add a handler for each one found
|
|
|
|
|
just add the addhandler inside the for loop
and then in the mnuunderdvd_click methode you'll need to check wich one is clicked
the sender object contains the clicked toolstripitem so if you do
dim mnu as toolstripmenuitem = sender
you can compare the text property of mnu or if you can add something (like the drive path/letter) to the tag property of the toolstripitem inside you for loop (in the load) and then compare this tag or use this tag to access the drive inside the mnuunderdvd_click methode
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Could I get around this by putting this in a single handler for all
Dim Drive_To_Read_DVD_From as string = sender.tostring
'' result being for example drive_to_read_DVD_From equaling D:\
then take it form there
|
|
|
|
|
see earlier post but I would store the drive path/letter in the tag property that way you can just use that value without altering it
also you need to cast the sender to toolstripmenuitem before you can access its property's
sender.tostring will just get you the type and somemore
so:
dim mnu as toolstripmenuitem = sender
mnu.text = 'text from the toolstripmenuitem clicked
mnu.tag = ' the tag property from the toolstripmenuitem clicked
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Hello,
Although I am not very clear about the scenario, I would like to inform you that we may create new menu items as ToolStripMenuItem object, and this item can be added as a sub menu to any existing ToolStripMenuItem using following code –
Dim PlayDvd As New ToolStripMenuItem
PlayDvd.Text = "New File"
Me.OpenToolStripMenuItem.DropDownItems.Add(PlayDvd)
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
can we write a code in vb which is equivalent to control c keyboad action, If yes pl provide me the code
Prakash Mishra(Banglore,India)
|
|
|
|
|
'Set form1 keypreview property to true'
'Add 2 labels
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.Control And e.KeyCode = Keys.C Then
Clipboard.Clear()
Clipboard.SetText(label1.text)
End If
If e.Control And e.KeyCode = Keys.V Then
Label2.Text = Clipboard.GetText()
End If
End Sub
Shay Noy
|
|
|
|
|
you want to copy certain text I presume.
this will usualy work without any code (if windows is the OS)
if you want another action to happen you'll need to catch the keydown event and check wether the control key and the c key are pressed.
Another way (perhaps better/easier) is to add a menustrip to you'r form (put it invisible)
and then in code (or design):
Dim mnuselectie As New ToolStripMenuItem("selectie")
mnuselectie.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.C), System.Windows.Forms.Keys)
AddHandler mnuselectie.Click, AddressOf mnuselectie_Click
msAlgemeen.Items.Add(mnuselectie) 'msalgemeen=menustrip on the form
then add code to mnuselectie_click
hope this helps
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
hi
I want to perform a the action like
1) select a file.
2)click the button ( here i want to perform 3 actions CntrlA + CntrlC + CntrlV) that is select all + Copy + Paste.
3) The output will get paste in a specified word file.
So i want on a button click these 3 action to get performed. Pl help
Prakash Mishra(Banglore,India)
|
|
|
|
|
I'll need a bit more information to answer this
the file is in wich format??
the file is on the hdd and you select it in you're programme or just in windows explorer??
the word file is specified in you're programme??
all the actions have to perform in sequence without any further user input??
you work with a button or a shortcut??
once the button is pressed you know the filepath and the word path??
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
thanks lot for your patience.
1)the action ( CntolA + ControlC) i want o perform on a pdf file
2)I want to create a browse button which will give the path of the pdf file)I think i have to open the file before performing the CntolA + ControlC action.
3)Then the i want a button say the name is action ( which will perform the events sequentially select all(pdf) + Copy + Paste(in word)
Hope i am clear to u this time
Regards
Prakash Mishra(Banglore,India)
|
|
|
|
|
|
hi friend,
i have a big problem which i dont know how to solve it,, it say's when i run the application "parameter is not valid"..and i look the error details that vb.net raise it about system.drawing.stream i run in visual studio .net 2005 i made it in vb.net then i deploy it to another laptop which is vaio model and windows xp prof. version 2002 sp 2 and it coz error..how can i fix that..is there a way to fix the problem...here's my code..
Public Sub LOAD_PICTURE_FROM_DBASE(ByVal i As String)
'Dim myconnection As New SqlConnection(My.Settings.CNString)
'Dim cmd As New SqlCommand("SELECT BLOBID, " & _
'"BLOBData FROM BLOBTest WHERE BLOBID=", DataGridView1.CurrentRow.Cells(0).Value)
Dim appRdr As New System.Configuration.AppSettingsReader
Dim myconnection As New Clsappconfiguration
'Dim myconnection As New SqlConnection(My.Settings.CNString)
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
cmd.CommandText = "select * from Temployee_picture where idnumber=" & "'" & i & "'" 'i & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = myconnection.sqlconn
myconnection.sqlconn.Open()
da.SelectCommand = cmd
da.Fill(ds, "Temployee_picture")
Dim c As Integer = ds.Tables("Temployee_picture").Rows.Count
If c > 0 Then
Dim bytBLOBData() As Byte = _
ds.Tables("Temployee_picture").Rows(c - 1)("picturedata")
Dim stmBLOBData As New MemoryStream(bytBLOBData)
emp_pic.Image = Image.FromStream(stmBLOBData)
Else
emp_pic.ImageLocation = Application.StartupPath & "\SplashScreen v3.jpg"
emp_pic.Load()
End If
myconnection.sqlconn.Close()
End Sub
that's the code that load picture from database...please reply me how to solve the this problem..parameter is not valid...
jhols
|
|
|
|
|
Hey
Firstly I cannot see where you are passing any parameters (only had a quick look are you planning on inserting them into the cmd string?) secondly you may be better using a stored procedure then adding the parameters eg:
cmd.Parameters.Add("@DOB", SqlDbType.DateTime).Value = DOB.Date;
Hope this helps
Dan
|
|
|
|
|
the error suggests that there is something wrong with the sql string.
did you try the sql string directly into the server?
my first idea would be to check the datatype of idnumber if it is a number (as the name suggests) then there is you'r mistake since you are trying to pass a string to it.
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
i was new in vb.net,and have explored and grew because of CodeProject and the books i bought and articles on the net. previous i got small projects that did not need a Dall and Bll, am afraid because i have been moved to large projects.So i need to learn BLL and DAl, how they work , how they commnicate, structuraly where and how to code them, and where to place them. i was looking at ASP.net DAL and BLL code, i understood, but am building desktop Applications. i would like anyone to point to an article or E-book to explains Dal and BLL for vb.net Desktop Application, that has to do with Database Programming.
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
The DAL and BLL will be the same as if you were doing a web app (pretty much) so for example you will have user inputs a string and clicks ok, this will get passed to say a user BLL object that in this case may format it (over simplified) which will then pass it to a user DAL object that will persist the data to your data store. No doubt the tutorials you looked at where at www.ASP.net so you can do the same with a desktop app but replace the User Interface (thats the beauty of an n-tier approach)
Hope this is of use
Dan
|
|
|
|
|
Thanks
very much it helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
Hi All,
I want to export data from sql Server into Excel in text format with Visual Basic 6.0. Becoz there are some value which are convert into date at export time, but actual value like 1144/05-06. If any one have some idea plz help me.
Thanx & Regards
SMK
|
|
|
|
|
|
Thanks For Replying ,
Now i am able to move the runtime controls on the form and place any where , no problem with that .Now i am in doing the things like these::
1) Setting the properties of those runtime controls
2) When i mouse down on that particular runtime control it has to display rectangles on edges of the control and able to resize the control.
I am searching the net . i got some answers ,But Trying if u have any resource links Give to me please ..
Regards
D.V.Sriram
|
|
|
|