Jump to content
Xtreme .Net Talk

Bucky

*Experts*
  • Posts

    803
  • Joined

  • Last visited

Everything posted by Bucky

  1. What you want to do is create a new Windows Control project. Go to the code of the control and change it to inherit TextBox instead of UserControl. Then create a subroutine that overrides the base class's OnKeyPress event. So, in your component, something like this: Public Overrides Sub OnKeyPress(sender As Object, e As KeyPressEventArgs) MyBase.OnKeyPress(sender, e) ' Call the base class method ' Add your code here that validates the key press End Sub Add a Windows Forms project to your solution, then reference the component project and test it out.
  2. I'm not sure if the class you're using is correct for what you want. The WebClient class does what you want easily. Check out [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemNetWebClientClassHeadersTopic.htm]the Headers collection[/mshelp] of the WebClient; there is even an example showing exactly what you want to do following that link.
  3. For setting the size and location, use the constructor of the Point and Size structures: tb1.Location = New Point(22, 22) tb1.Size = New Size(280, 15) As for accessing the control later, store it in a form-level variable that you can change properties of and such, or remove from the Controls collection when you want to remove it. ' This is in general declarations: Dim myControl As TextBox ' Then, when you want to init it: myControl = New TextBox() ' Set the properties here Me.Controls.Add(myControl) ' And to dispose of it: Me.Controls.Remove(myControl) myControl.Dispose() myControl = Nothing
  4. You need to go to the Project menu -> References, and add a reference to the System.Management DLL in your project.
  5. Adding controls to forms dynamically is the same for native .NET controls and for ActiveX ones. For example, to add a TextBox to a form: Dim txtToAdd As New TextBox() ' Set the properties here, including location and size Me.Controls.Add(txtToAdd)
  6. Drstein, I see where your problem lies. 'tb1.Location.X.Equals(22) 'tb1.Location.Y.Equals(22) tb1.Size.Height.Equals(15) tb1.Size.Width.Equals(280) I see that the first two lines are commented out, but you made the same mistake for all four. The Equals method that all types have is a function that returns a boolean value telling whether the value passed to it is equal to the object itself. It is not a setter function such as you might have in a property declaration. It is just a function that returns a value. Your code will work correctly if you use the = operator like so: tb1.Location.X = 22 tb1.Location.Y = 22 tb1.Size.Height = 15 tb1.Size.Width = 280
  7. VS.NET supports the creation of Deployment Projects; you should have a look there, first. [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/vsintro7/html/vbconDeployingSolution.htm]Read on![/mshelp]
  8. Instead of popping up a dialog, log the user in and direct them to a page where they can decide. Have buttons or links on the page for "yes" or "no", where "yes" brings them to the page to change the password, and "no" continues on with their browsing.
  9. Or Application.DoEvents()
  10. Both the ArrayList and HashTable classes are marked with the Serializable attribute, so as long as the classes in the collections are also Serializable you shuld be all set.
  11. The framework does not need to be "enabled" if it's installed on a machine; it's just a bunch of DLLs (and other things) that can be accessed any time.
  12. One of XML's strong points is that it's universal; any XML parser application on any platform can get the same data from a file. XML web services exploit this ability in a good way: they return data in a specific XML protocol, SOAP, so that anybody can interpret it. So if you're looking for interoperability, that is, transferring data beteen apps, languages, and platforms, XML is the way to go.
  13. XML: http://www.w3schools.com/xml/default.asp XSL: http://www.w3schools.com/xsl/default.asp In a nutshell, XML is a way to store data, and XSL is a way to format it for displaying.
  14. It's not that difficult; just look at the similarities between this code and the above: // All this goes in general declarations: [DLLImport("winmm.dll")] public int sndPlaySound(string path, int flags) {} const int SND_ASYNC = 0x1 const int SND_FILENAME = 0x20000 // And to play the sound: sndPlaySound("C:\MySound.wav", SND_ASYNC | SND_FILENAME);
  15. You could also [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpovrserializingobjects.htm]use serialization[/mshelp] of a class that stores all the settings and documents. To store the rich text files in the class, just set some String properties to the RTF text you're storing (RichTextBox.TextRTF, for example).
  16. [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemStringClassSplitTopic.htm]String.Split()[/mshelp] Also, the most comprehensive site I could find on Beakman. :)
  17. When your code is running, nothing else in the system is. Your app is using up all of the processor's time, for however short or long. A call to DoEvents() stops your code for a split-second and allows Windows to process other messages, which in this case would be the message to redraw your control. By putting it in a loop, the code in the Invalidated event is given sufficient time to execute, and your other code will only continue when the boolean value is set to true. [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemWindowsFormsApplicationClassDoEventsTopic.htm]Read more![/mshelp]
  18. You can access the controls on the form and their properties. Just get the values of the Text properties of the textboxes: Dim frm As New myForm() frm.ShowDialog() whatever = frm.txtEdit.Text ' etc. etc.
  19. Oh... databases aren't my forté, so I didn't get that's what you were doing there. In that case, then, your way is probably more logical, unless you want to split up the data string and do it that way. *shrug* As for your error handling, try the ToString() method of the Exception class; it provides a nice summary of the error which is very similar to the one you concatenate in your Catch handler. Also, my avatar is of Paul Zaloom who played Beakman on Beakman's World. I used to think that was the greatest show.
  20. I'd like to add another questions here that is somewhat related, although I'm sure the answers will be along the lines of "it depends": Is it "better" to have a lot of experience or training in a few specialized fields, or is it "better" to have a little experience or training in a wide array of languages, platforms, concepts, etc.? I understand it'd probably be "best" to be an expert in every subject, but we can't all be Renaissance Men and Women.
  21. The FileSystemWatcher is much more efficient and proper to use. It creates a system-wide hook that receives messages whenever file changes take place. It is only "running" when it's needed, but your method is hogging (no pun intended) all kinds of system resources.
  22. How about reading the entire text file into a string first, and then sticking it in the DB? Dim arrBytes() As Byte Dim fFile1 As FileStream = File.Open(Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\p1.txt", _ FileMode.Open, FileAccess.Read) Dim reader As New StreamReader(fFile1) Dim data As String reader.ReadBlock(arrBytes, 0, fFile1.Length) data = System.Text.Encoding.UTF8.GetString(arrBytes) Is that slightly more elegant?
  23. How are you storing and saving the settings? Serialization? A strongly-typed DataSet? Manipulation of an XmlDocument object? Something else?
  24. If I understand correctly, this may help. Create a boolean variable that's set to false before calling Invalidate. Create an OnInvalidated method (or a handler for the Invalidated event), and then set the boolean value to true. In the code where you need to wait for the invalidate to complete, make a little loop that exits when the boolean variable is set to true, and stick an Application.DoEvents() call in the loop to give it time to process.
  25. Look into the ListView's Sort() method and its ListViewItemSorter property.
×
×
  • Create New...