snarfblam
Leaders-
Posts
2156 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by snarfblam
-
I was not recommending using DrawString in a textbox.
-
Is there a SelectedValue property? Or are you referring to SelectedItem? Like PlausiblyDamp said, check the value of SelectedItem (or SelectedItem.ToString). Could be that it is nothing or an invalid string. Check either that (.SelectedIndex <> -1) or that (Not .SelectedItem Is Nothing).
-
Assuming that you are storing the existing's centers and radii in an array, Why can't you just loop through the existing circles and see if they overlap. I was bored so I made this: Structure Circle Dim Radius As Single Dim Location As PointF Shared Randomness As Random ' Shared Sub New() Randomness = New Random End Sub ' Public Sub New(ByVal MinRad As Single, ByVal MaxRad As Single, ByVal Region As RectangleF) Radius = CSng(Randomness.NextDouble() * (MaxRad - MinRad) + MinRad) Location.X = CSng(Randomness.NextDouble() * (Region.Width) + Region.Left) Location.Y = CSng(Randomness.NextDouble() * (Region.Height) + Region.Y) End Sub ' Public Function Overlaps(ByVal WithWhat As Circle) As Boolean 'If the distance of the centers is less than the sum of the radii then they overlap If ((WithWhat.Location.X - Me.Location.X) ^ 2 + _ (WithWhat.Location.Y - Me.Location.Y) ^ 2) ^ 0.5 _ < Me.Radius + WithWhat.Radius Then Return True Else Return False End If End Function ' Public ReadOnly Property ContainingRect() As RectangleF Get Return New RectangleF(Location.X - Radius, Location.Y - Radius, Radius * 2, Radius * 2) End Get End Property End Structure ' Dim Circles(9) As Circle ' Private Sub MakeSomeCirclesForMeBaby() Dim Overlap As Boolean = False For i As Integer = 0 To Circles.Length - 1 Do 'We will create new random circles using the constructor and loop until 'it does not overlap with any previous (j to 0) circles Circles(i) = New Circle(0, 10, New RectangleF(0, 0, 100, 100)) Overlap = False For j As Integer = i - 1 To 0 Step -1 If Circles(j).Overlaps(Circles(i)) Then Overlap = True End If Next Loop While Overlap Next End Sub
-
The .TextAlign property is of type System.Windows.Forms.HorizontalAlignment. You can not use System.Drawing.ContentAlignment members for a text box. Textboxes do not support any type of vertical alignment except the default. Have you tried making a UserControl that draws the text? Labels and textboxes are meant for different uses and do not have much functionability in common beyond the fact that they both contain text. You want to show unicode chars, but a label can't do this, right? You want to vertically center the text and add background images, but a textbox can't do this. I don't know if the Graphics.DrawString() method will draw the chinese characters you need, but I'm guessing that more likely than not it will. Try it, and if it works, make a user control.
-
Look up AddHandler in the Help. The Handles clause (in conjuntion with WithEvents) in VB essentially breaks down to the same thing as using AddHandler, it is just easier on the eyes. When you instantiate each object in the array, use the AddHandler statement to add the event handlers. Dim btnButtonsGalore As Button() = New Button(16) {} Sub Populate For i As Integer = 0 To btnButtonsGalore.Length() - 1 btnButtonsGalore(i) = New Button AddHandler btnButtonsGalore(i).Click, AddressOf btnButtonsGalore_Click Next i End Sub Sub btnButtonsGalore_Click(sender As Object, e As EventArgs) '... End Sub
-
Sorry. My bad.
-
Why is it that a textbox will support chinese characters but not a label (under 98/ME)? They both use unicode, right? Same fonts, same character sets? [Edit]Have you tried drawing your own text with the Graphics.DrawString() method to see if that worked for chinese chars?[/Edit]
-
Brackets? We were just talking about curly braces. And admittedly, ReDim works just fine, but it is considered the old way of doing things, not the new .NET way. Seems like everyone wants to do things the .NET way. But I think ReDim is really just there for portability between vb6 and VB.NET.
-
Try an amazon.com book search for C++.Net. I personally can't recommend any good books.
-
In .Net Microsoft took a more logical approach and made the default button a property of the form rather than of the button. Select the form in the designer, and look in the properties. The property is "AcceptButton". Also note the "CancelButton" property.
-
I didn't look to far into it, but it looks like this might help: http://www.xtremedotnettalk.com/showthread.php?t=49407
-
I don't really see a background image working so swell in a textbox. It would probably become difficult to read the text unless the image is very light. Textbox does inherit the .BackgroundImage property from the Control class, however it does not do anything.
-
He said is experience was vb6. Thats is why we recommended vb.net as an intermediate step. If you are programming with unmanaged code, is there an advantage to using C++ .Net over Visual C++ 6?
-
Yeah, you do need to add it to the control collection before bringing it in front. Otherwise it does not have a collection of controls that it can be brought in front of.
-
I was under the impression that a zero length string was not considered to be equal to nothing (because a zero length string could still be instantiated and hence not a null reference, i.e. nothing), but I checked and appearently I was wrong.
-
If TextBox1.Text.Trim <> String.Empty Then 'Don't know if you want the replaced with text to be trimmed. ttext = ttext.Replace("<patientname>", TextBox1.Text.Trim) '<-- But it is here. End If This, like DiverDan's example, will not convert your string to proper casing. I do not know how to do this (I didn't even know that there was a VB function for this).
-
I learned what I know about c++ (not .NET, though, but Visual C++ 6.0) from Ivor Horton's "Beginning Visual C++". VB6 to C++ is a big jump, though. I know it was for me. I would also recommend VB.Net first, to learn not only OOP but about the .Net framework. C++ .Net isn't a completely different language from VB.Net. In addition to sharing the .NET framework, it shares many programming concepts with VB.Net that it does not share with VB6. It is a bit much to pick up a new syntax, a new framework, and OOP all at the same time. You can get two of them in the first round with VB.Net and still remain in the familiar Visual Basic environment.
-
I have been wondering about this myself. If the pictures are stored, say, in PictureBoxes, I beleived that the images would need to be loaded and instantiated from the app's embedded resources for each instance of the control, and hence duplicated. No guarantees, but if you create a shared ImageList and load your images into the ImageList (via a shared constructor) and then set your PictureBox's .Picture property to the images from the ImageList, I believe that all six images could be shared between instances. But... I wouldn't know exactly how to do this.
-
In your main form you can store a reference to the opened form and handle its closed event and in the handler re-enable the menu item. Also, just a recommendation: Instead of disabling the menu items, when the user clicks a menu item that should open a form that is already open, why not just focus that form. That is what I usually do.
-
Can you not add the .vb files from project a to project b? Just right click project b in the solution explorer, and click Add > Existing Items... and browse to and add the files you want in the project a folder.
-
Hm... you can't make a virtual static member. You can shadow it, but if it is called from a variable of type A that points to a B then that won't work as desired. It seems that what you are trying to do is really contrary to the nature of the static method. You probably know this, but a static function call is effectively independant of any instance of the class in which it is defined or any derived class; it is not actually called from the B class. If you declare a varable [b myvariable;] where class B inherits from A, the compiler will interperet myvariable.Select() exactly the same as A.Select(). There is no way to detect if it was an instance of the derived class because it gets compiled as though it wasn't. Why is it that you need to know the calling type, or why can't you create two functions?
-
Yeah... I'm not sure that I got all that. But that is a good point; in Form2's closing event, you would want to set e.Cancel to True, and call Me.Hide. You would also want Form2 to clear any textboxes, reset any labels that were changed, etc. each time it is shown.
-
I don't know if this will work but try instantiating but not showing the form as soon as you know that you will need it. If, for example, you know that a dialog that you created will be used frequently, instantiate it when the app loads. Declare a variable initialized to a reference of a new instance of this form (like Dim frmEntryEditor as new EntryEditor). The form will be initialized, but not shown until you call frmEntryEditor.Show(). There is no way, of course, to do this for your main form.
-
Hey, chill out. Its two keystrokes and basic has been doing arrays with parentheses since the 1980s. Change it now and a lot of people will get mad.
-
So sorry Hey pal I was just giving a recommendation, and for that matter trying to help. A lot of people hate when you override their color preferences.