|
Let me try to convert to VB.net. I'll let you know.
Thanks
|
|
|
|
|
Thank you Robert!!
I tried but I don't think I have this correct. Please give me some advise:
Imports Crownwood.Magic.Menus<br />
Imports Crownwood.Magic.Common<br />
Imports Crownwood.Magic.Controls<br />
<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
<br />
#Region " Windows Form Designer generated code "<br />
<br />
Public Sub New()<br />
MyBase.New()<br />
<br />
'This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
'Add any initialization after the InitializeComponent() call<br />
<br />
End Sub<br />
<br />
'Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
<br />
'Required by the Windows Form Designer<br />
Private components As System.ComponentModel.IContainer<br />
<br />
'NOTE: The following procedure is required by the Windows Form Designer<br />
'It can be modified using the Windows Form Designer. <br />
'Do not modify it using the code editor.<br />
Friend WithEvents _menuMain As Crownwood.Magic.Menus.MenuControl<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
Me._menuMain = New Crownwood.Magic.Menus.MenuControl<br />
Me.SuspendLayout()<br />
'<br />
'_menuMain<br />
'<br />
Me._menuMain.AnimateStyle = Crownwood.Magic.Menus.Animation.System<br />
Me._menuMain.AnimateTime = 100<br />
Me._menuMain.Cursor = System.Windows.Forms.Cursors.Arrow<br />
Me._menuMain.Direction = Crownwood.Magic.Common.Direction.Horizontal<br />
Me._menuMain.Dock = System.Windows.Forms.DockStyle.Top<br />
Me._menuMain.Font = New System.Drawing.Font("Tahoma", 11.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, CType(0, Byte))<br />
Me._menuMain.HighlightTextColor = System.Drawing.SystemColors.MenuText<br />
Me._menuMain.Location = New System.Drawing.Point(0, 0)<br />
Me._menuMain.Name = "_menuMain"<br />
Me._menuMain.Size = New System.Drawing.Size(292, 25)<br />
Me._menuMain.Style = Crownwood.Magic.Common.VisualStyle.IDE<br />
Me._menuMain.TabIndex = 0<br />
Me._menuMain.TabStop = False<br />
Me._menuMain.Text = "MenuControl1"<br />
'<br />
'Form1<br />
'<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
Me.ClientSize = New System.Drawing.Size(292, 273)<br />
Me.Controls.Add(Me._menuMain)<br />
Me.Name = "Form1"<br />
Me.Text = "Form1"<br />
Me.ResumeLayout(False)<br />
<br />
End Sub<br />
<br />
#End Region<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
AddMenu()<br />
End Sub<br />
<br />
Protected Sub AddMenu()<br />
Dim topLevelCommand = New MenuCommand<br />
<br />
topLevelCommand.Text = "File"<br />
_menuMain.MenuCommands.Add(topLevelCommand)<br />
<br />
Dim subLevelCommand1 = New MenuCommand subLevelCommand1.Text = "Exit"<br />
AddHandler subLevelCommand1.Click, AddressOf OnExitSelected<br />
topLevelCommand.MenuCommands.Add(subLevelCommand1)<br />
<br />
End Sub<br />
<br />
Public Sub OnExitSelected()<br />
<br />
End Sub<br />
<br />
End Class
I am getting an error in the MenuCommand of:
New MenuCommand
but I fixed this by adding the following Imports:
Imports Crownwood.Magic.Menus
Imports Crownwood.Magic.Common
Imports Crownwood.Magic.Controls
I am getting an error in the AddHandler .Click:
'Click' is not an event of 'System.Object'
I can't figure this one out.
|
|
|
|
|
You are very close
The problem comes from you variable definition:
Dim subLevelCommand1 = New MenuCommand
is implicitely translated by the compiler to this:
Dim subLevelCommand1 as Object
subLevelCommand1 = New MenuCommand
Thus you have an Object variable with just a MenuCommand as it contents, but the compiler isn't aware of that. Correct it should be:
Dim subLevelCommand1 as MenuCommand = New MenuCommand
Also the signature of the function OnExitSelected has to be changed:
Public Sub OnExitSelected(ByVal sender As Object, ByVal e As EventArgs)
Me.Close()
End Sub
Now everything should work fine
|
|
|
|
|
I would assume that this is also the way to add any control to the form programmatically:
Dim subLevelCommand1 as MenuCommand = New (type of control)MenuCommand
I came from the Alpha Micro world which was strictly ascii, no graphics. OOP is totally new to me. I do have a 1 foot stack of books on VB.NET but that is overwhelming. One step(or line) at a time.
Many Thanks!!!
|
|
|
|
|
No. Controls are added to a form this way:
Dim btn as Button = New Button
btn.Text = "Hello"
btn.Left = 10
btn.Top = 30
myForm.Controls.Add(btn)
|
|
|
|
|
I am writing some code in VB.NET which I parse a string to remove the domain name and back slash but the back slash remains in the TextBox. Here is the code.
Dim myStartPointer As Integer = Me.ebLoginName.Text().IndexOf("\")
Dim myLength As Integer = Me.ebLoginName.TextLength()
If myStartPointer > 0 Then
Me.ebLoginName.Text() = Mid(Me.ebLoginName.Text(), _
myStartPointer + 2, myLength - myStartPointer + 1)
Me.mccDomain.Clear()
End If
Bob Zagars
Senior Software Engineer
|
|
|
|
|
Domain names have forward slashes in front of them, not back slashes. For example:
http://www.codeproject.com
|
|
|
|
|
Sorry for the wrong term been working long hours. Still should I re-post or can you answer my question?
Bob Zagars
Senior Software Engineer
-- modified at 14:47 Saturday 14th January, 2006
|
|
|
|
|
But in your code you are doing a string search for a back slash.
Dim myStartPointer As Integer = Me.ebLoginName.Text().IndexOf("\")
Or was this a typo too?
|
|
|
|
|
Then it is back slash.
A domain name is prefixed wih DOMANINAME\username.
When a user is defined with Windows Authentication it uses this format listed above. The original code was correct and works but does not remove the BACK SLASH.
If a user want Windows Authentication the domain name is necessary, otherwise it is the user name and a password has to be entered in another location on the form.
This is not a TYPO!
Bob Zagars
Senior Software Engineer
|
|
|
|
|
The issue is on line 3. If the first character in the string is a '\', which it likely will be with a path such as "\\Foo\Bar", then the index will be zero causing it to skip over your If condition.
You should change it to >= 0, like this...
If myStartPointer >= 0 Then
|
|
|
|
|
That would cause a problem if the back slash was at postion 0. This error happens even when the position is in the middle of the string.
Example MYDOMAINNAME\myusername
The results is from my code \myusername
If I add one to the start position of the Mid() method I will get \yusername
The code has nothing to do with the starting position it has to do with the removal of the back slash.
Bob Zagars
Senior Software Engineer
|
|
|
|
|
Bob Zagars wrote: That would cause a problem if the back slash was at postion 0. This error happens even when the position is in the middle of the string.
Your code has 2 bugs in it then. The first one I already mentioned. The second bug is with how you're extracting the substring.
You are being confused by the Mid() function. Mid() is a function that was used in VB6 and only exists in VB.NET for compatibility reasons. Mid() expects 1 based indexes, which is the way indexing used to work in VB6. The .NET String class uses zero based indexes. This is why you are one character off.
You should call String.Substring() instead.
|
|
|
|
|
Dim myStartPointer As Integer = Me.ebLoginName.Text().IndexOf("\")<br />
Dim myLength As Integer = Me.ebLoginName.TextLength()<br />
Dim myString As String = Me.ebLoginName.Text()<br />
If myStartPointer >= 0 Then<br />
Me.ebLoginName.Text() = myString.Substring(myStartPointer + 1)<br />
Me.mccDomain.Clear()<br />
End If
Same problem can not get rid of back slash.
myStartPointer is suppose to be the indexed location of the back slash.
Input string MYDOMAINNAME\test
Results \test
Bob Zagars
Senior Software Engineer
|
|
|
|
|
Bob Zagars wrote: Dim myStartPointer As Integer = Me.ebLoginName.Text().IndexOf("\")
Dim myLength As Integer = Me.ebLoginName.TextLength()
Dim myString As String = Me.ebLoginName.Text()
If myStartPointer >= 0 Then
Me.ebLoginName.Text() = myString.Substring(myStartPointer + 1)
Me.mccDomain.Clear()
End If
I've just ran your above code with the string "MYDOMAIN\test". It worked for me. Either the input string is not what you expected or the problem lies elsewhere in your code. In either case, I recommend that you step through your code in the debugger and keep a sharp eye on your ebLoginName.Text property.
|
|
|
|
|
Joshua Quick wrote: Dim myStartPointer As Integer = Me.ebLoginName.Text().IndexOf("\")
Dim myLength As Integer = Me.ebLoginName.TextLength()
Dim myString As String = Me.ebLoginName.Text()
If myStartPointer >= 0 Then
Me.ebLoginName.Text() = myString.Substring(myStartPointer + 1)
Me.mccDomain.Clear()
End If
I've just ran your above code with the string "MYDOMAIN\test". It worked for me. Either the input string is not what you expected or the problem lies elsewhere in your code. In either case, I recommend that you step through your code in the debugger and keep a sharp eye on your ebLoginName.Text property.
Okay this tells me something because I thought I was crazy and could not understand how my results kept adding a back slash. I am using a class library from Janus Systems. It is their EditBox which has to be the problem. I will submit at their web site.
Thanks for your help.
Bob Zagars
Senior Software Engineer
|
|
|
|
|
You are dead wrong. Here is the class String Indexof() method.
"Reports the index of the first occurrence of the specified String in this instance."
....
"Return Value
The index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is 0."
I have not tested at the first position which might be position 0 or 1 but my problem is not related to this issue. Mine happens in the middle of the string.
Bob Zagars
Senior Software Engineer
|
|
|
|
|
Bob Zagars wrote: You are dead wrong.
I'm not wrong. Your code does fail if a back slash is found at index 0. Try this string: "\\Foo".
|
|
|
|
|
Joshua Quick wrote: I'm not wrong. Your code does fail if a back slash is found at index 0. Try this string: "\\Foo".
I am sorry but my code will never have "\\" in it only DOMAINNAME\username which I am getting off the problem, If you do not have an answer that will solve my problem stop replying.
Bob Zagars
Senior Software Engineer
|
|
|
|
|
you can use the Replace method of the string.
newstring = strbackslash.Replace("\","")
|
|
|
|
|
Or just get the code right in the first place and forget about this little "patch".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i was told i need to use invoke to marshal to fix this exception : Control 'TxtFolderActivity' accessed from a thread other than the thread it was created on. i cant seem to figure it out. here is the snippet of code where i need the invoke.
<br />
<br />
Private Sub logchange(ByVal source As Object, ByVal e As _<br />
System.IO.FileSystemEventArgs)<br />
<br />
<br />
If e.ChangeType = IO.WatcherChangeTypes.Changed Then<br />
TxtFolderActivity.Text &= "File " & e.FullPath & _<br />
" has been modified" & vbCrLf<br />
End If<br />
<br />
If e.ChangeType = IO.WatcherChangeTypes.Created Then<br />
TxtFolderActivity.Text &= "File " & e.FullPath & _<br />
" has been created" & vbCrLf<br />
End If<br />
If e.ChangeType = IO.WatcherChangeTypes.Deleted Then<br />
TxtFolderActivity.Text &= "File " & e.FullPath & _<br />
" has been deleted" & vbCrLf<br />
<br />
End If<br />
<br />
End Sub<br />
Makniteasy
|
|
|
|
|
You're not allowed to interact with a Form on a separate thread.
What you need to do is call BeginInvoke(). What this will do is push a delegate to the end of the Windows message queue. That delegate will be invoked on the UI thread, which will allow you to safely write your string to the TextBox.
The following article has more information. See the code example at the bottom.
http://www.codeproject.com/csharp/begininvoke.asp[^]
|
|
|
|
|
If I have a web form, and a button. How do I work it that when that button is pressed it will redirect the user to another webform. And on that new webform there will be a standard label, and the labels text will change to a value specified in the button on the first web form.
Does that make sense? Hope it does, any help appreciated.
|
|
|
|
|
Hi
to move from one page to another (redirect) use this code
server.transfer("Your Path or the form name you want to go to")
ex: server.transfer("WebForm2.aspx")
to make the label on the second page change and to pass a certain value to it you can do that in different ways:
1. to set a cookie value and retreive it on the form
2. to pass the value as a URL variable to the new form
3. to set a session and retreive its value on the new form
I hope that i have helped you!
Best wishes
Regards
Mohammad Rabay'a
|
|
|
|