|
Hello again:
I have use a component class that inherits from the MenuItem class: this is the class:
Imports System.ComponentModel
<description("owner draw="" menuitem="" class="" with="" new="" properties="" such="" as="" image="" and="" font.")=""> _
Public Class MiMenuItem
Inherits MenuItem
Private mFont As Font = SystemInformation.MenuFont
Private mImage As System.Drawing.Image = Nothing
Private nStartTextPosition As Integer = 0
Public Sub New()
MyBase.New()
End Sub
<description("position of="" the="" left="" corner="" menuitem="" control="" where="" text="" is="" drawing"),="" defaultvalue(0)=""> _
Property StartTextPosition() As Integer
Get
StartTextPosition = nStartTextPosition
End Get
Set(ByVal Value As Integer)
nStartTextPosition = Value
End Set
End Property
<description("the font="" used="" to="" draw="" the="" text")=""> Property Font() As System.Drawing.Font
Get
Font = mFont
End Get
Set(ByVal Value As Font)
mFont = Value
End Set
End Property
<description("this image="" will="" be="" used="" on="" the="" left="" side="" menuitem.note:="" this="" is="" visible="" only="" at="" run-time="" !")=""> Property Image() As Image
Get
Image = mImage
End Get
Set(ByVal Value As Image)
mImage = Value
End Set
End Property
Protected Overrides Sub OnMeasureItem(ByVal e As System.Windows.Forms.MeasureItemEventArgs)
Dim itemSize As SizeF
itemSize = e.Graphics.MeasureString(Me.Text, mFont)
Dim nIconW As Integer = 0
Dim nIconH As Integer = 0
If Not (mImage Is Nothing) Then
nIconW = mImage.Width
If mImage.Height > itemSize.Height Then nIconH = mImage.Height - itemSize.Height
End If
e.ItemWidth = itemSize.Width + nIconW + nStartTextPosition
e.ItemHeight = itemSize.Height + nIconH
End Sub
Protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs)
Dim selected As Boolean
Dim textcolor As Color = SystemColors.MenuText
Dim textformat As New StringFormat()
textformat.HotkeyPrefix = Drawing.Text.HotkeyPrefix.Show
Dim nIconW As Integer = 0
If Not (mImage Is Nothing) Then
nIconW = mImage.Width
End If
Dim R As New RectangleF(e.Bounds.Left + nIconW, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height)
selected = (e.State And DrawItemState.Selected)
e.Graphics.FillRectangle(SystemBrushes.Menu, e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height)
If selected Then
e.DrawBackground()
textcolor = SystemColors.HighlightText
Else
e.Graphics.FillRectangle(SystemBrushes.Menu, R)
End If
If Not (mImage Is Nothing) Then
e.Graphics.DrawImageUnscaled(mImage, e.Bounds.Left, e.Bounds.Top)
End If
R.X += nStartTextPosition
e.Graphics.DrawString(Me.Text, mFont, New SolidBrush(textcolor), R, textformat)
End Sub
End Class
>>>>>>>>>>>>>>>>>
Now you need to change the line where you define the menu Item and the line where you define the instance of that MenuItem of your menu:
Friend WithEvents MenuExit As System.Windows.Forms.MenuItem
Me.MenuExit = New System.Windows.Forms.MenuItem
for your new component
Friend WithEvents MenuExit As miMenuItem
Me.MenuExit = New MiProyect.MiMenuItem
Finally, define the type of Font and Image you want, you can use the properties browser to change this fields.
Me.MenuExit.Font = New System.Drawing.Font("Tahoma", 11.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, CType(0, Byte))
Me.MenuExit.Image = CType(resources.GetObject("MenuExit.Image"), System.Drawing.Image)
Hope this Helps!
JA
|
|
|
|
|
Is there a simple way to prevent users from using the Ctrl-Esc key combo? I would prefer not using a keyhook
|
|
|
|
|
The only way your going to do that is to write the keyboard hook.
RageInTheMachine9532
|
|
|
|
|
I've been trying to work out for the last few weeks how to send text from a TextBox to a web form from my VB app. Im in the midst of making a chat client for a web site, and havent been given access to the DB, so i have to work with the current forms
Any help for this will be great, for it will assist me in further enhancements to the program.
-Warder
Project Insanity lives
.... sort of. =/
www.projectinsanity.cjb.net
|
|
|
|
|
Hi all,
I need to draw a chart using VB with data from an excel sheet . How should the code be like if I want to have column A to be in the x-Axis and column B data to be the y axis. Please Help. Thanks
Below is my code that charts, but the data info is not what i want
oSheet3.Range("A1").Resize(51, 1).Value = ChartXDataArray
oSheet3.Range("B1").Resize(51, 1).Value = ChartYDataArray
Dim ch As Object
Dim chart1 As Object
Set ch = oSheet3.ChartObjects.Add(100, 30, 350, 270)
Set chart1 = ch.Chart
' chart1.Name = "NAme"
chart1.ChartType = xlColumnStacked
chart1.SetSourceData Source:=oSheet3.Range("B1:B51"), _
PlotBy:=xlColumns
chart1.SetSourceData Source:=oSheet3.Range("A1:A51"), _
PlotBy:=ylColumns
chart1.HasLegend = False
|
|
|
|
|
Hi,
Anyone know a way to allow editing cells in a .net datagrid, while preventing an insert? I wish to avoid having the "add" line appear with the telltale asterisk. The data needs to be editable, but users can not be allowed to add new recs.
Thanks in advance.
cheers,
Bill
Bill Polewchak
Team Leader
Software Development/Architecture
Avery Dennison Corp.
|
|
|
|
|
|
Hello everyone!
I am new to this site & to VB.NET.
I have got following problem.
I have 3 listbox and one datagrid control on my form.
I have 4 tables like-> Customer,City,Area,Country
Relation between these tables is like so:
1 Country --> Many Cities
1 city --> Many Areas
1 Area --> Many Customers
Now what I want to do is that when form is loaded then country names are displayed in listbox1, when user selects a country, all cities of that country are displayed in listbox 2, and when user selects a city then its areas are displayed, and finally when user selects an area then customers of that area are displayed in datagrid.
I have tried selectedindex property of listbox to solve this problem.
Can anyone give me a better suggestion.
I'll be thankful if you can help me by providing an example for it, it'll be easier for me to understand it then.
Thanx.
want to learn.
|
|
|
|
|
Try this.
Public Structure uListElement
Public ID as integer
Public Name as string
Public Override Function ToString() as String
Return Name
End Function
End Structure
Now, fill the listbox1 with this structure, where each element in the structure is a ListElement, e.g.
Dim vElement as uListElement
vElement.ID=CountryCode
vElement.Name=CountryName
ListBox1.Items.Add(uListElement)
In the ListBox1 SelectedIndexChanged event, cast the SelectedItem into a uListItem and you can get the ID of the selected country. Once you have the element, you can execute a select on the datatable of the cities that belongs to the country you just selected. Then you can repeat the same for the Areas and Customers... Got the idea ?
Free your mind...
|
|
|
|
|
In order to solve your problem you need to do the following steps.
try to use procedures always
1)write a code for filiing countries name and can be placed in form load event.
2)write a code in that pass sql query as <select cityID,city from city where cityID=cmbcountryfilled.selectedvalue> and place this code in selection change commited event of country combo.and do the same for area.i ohope it will work.
before that it depends how you are filling the combo.try to use dataset and fill the combo.
please get back to me if you have any doubt...
|
|
|
|
|
Is there any way by which i can find out the name of the current running schedule task.
[consider multiple schedule tasks running at a time.]
For more info on scheduler task component please refer following links;
http://www.codeproject.com/csharp/taskschedulerlibrary.asp
http://www.codeproject.com/csharp/TSNewLib.asp
|
|
|
|
|
|
Use GetTaskNames() to get a list of all the task names. Iterate through the list, using the name to access each task. Ask each task for its Status . If the status is Running then you have a running task. Do with this what you want.
--Colin Mackay--
|
|
|
|
|
I am creating an new scheduled task using vb.net.
I need to pass a parameter to it.
Can it be done in name=value format.
Also how can i read it in other vb.net program which is scheduled.
For e.g., If I pass parameter as follows:
t.Parameters = "name=" & name
then
how can i read this parameter from the scheduled program.
For more info on scheduler task component please refer following links;
http://www.codeproject.com/csharp/taskschedulerlibrary.asp
http://www.codeproject.com/csharp/TSNewLib.asp
Thanks for obliging.
|
|
|
|
|
|
Use Environment.GetCommandLineArgs() to retrieve the parameters passed into your application. This will return a string array each element containing an argument.
You have to define a way to work with these arguments, so if you prefer you can of course use a name=value format. However it is completely up to you.
--Colin Mackay--
|
|
|
|
|
Can anyone tell me how to recursively copy/delete files in VB.NET?
|
|
|
|
|
Send me you email address and I'll send you sample.
BenBadger@Comcast.net
|
|
|
|
|
Why don't you publish the example here ?
That's the idea of the forum, everybody learns...
Free your mind...
|
|
|
|
|
I have already done it.
Besides, you come from comcast.net, which is one of the biggest SPAM senders on the Internet.
Never will you get my e-mail address
|
|
|
|
|
Anonymous wrote:
Besides, you come from comcast.net, which is one of the biggest SPAM senders on the Internet.
How odd that I've never gotten a SPAM originating from a Comcast IP. But I know what your talking about. Machines on Comcast's network, as well as others, have been hijacked by trojan horses to send out a few hundred SPAM's at a time, here and there, so the users won't notice the extra traffic on their connections. It's s a very sneaky way to get around SPAM blockers that block by source domain.
Comcast is pretty strict about not running servers on your connection. Believe me, I've been hassled more than a few times about the web/ftp servers I run for my own private use. In my experience, someone sending out millions, if not thousands of SPAM's would get disconnected pretty quick for violating the TOS.
RageInTheMachine9532
|
|
|
|
|
Hi!
I am new to VB, and have a project for our library that requires some VB programming to compare two excel wbooks. The idea is to compare two alphabetical lists of journals, and combine the records, where they are repeated in both lists, to a third list that weeds out duplicates, and records only the most complete record.
Do any of you have suggestions on how this code should look?
Thanks tons.
|
|
|
|
|
I'm also new to VB.. relatively. Anyway, if you are dealing with Excel, u can use VBA( Visual Basic Application) to do that. That's what i'm using now for VB6 developer. But I think it still works for VB.NET ,... not too sure.
That's for the code language to look out for. As for the design, Have to think about it... but shoul be easy once you got hold of the language. (At least I feel its easier than the language itself for beginners)
|
|
|
|
|
1. How to show the calender dropdown on DateTimePicker control using the keyboard? (Is there a command like the combobox control - combo.droppeddown=true - to show the dropdown list)
2. How can I make DateTimePicker control to have flat appearence?
3. How to make DateTimepicker Control to accept Null/empty Value?
4. Can I make the DataGridBoolColumn to have flat apperance?
Thanks
|
|
|
|
|
Hi, I'm having the same problem. Did you solve this?
/=/=/=/= Sagmam =\=\=\=\
|
|
|
|