Jump to content
Xtreme .Net Talk

Bucky

*Experts*
  • Posts

    803
  • Joined

  • Last visited

Everything posted by Bucky

  1. I use the Regex.Split() function, which allows you to split a string by a delimeter that is not just a single character. For example, this splits the sentence into multiple words: string[] words; string text = "This is a test, yo."; words = System.Text.RegularExpressions.Regex.Split(text, " ");
  2. Make sure the Height and Width of the ImageSize don't exceed 256; anything larger throws an ArgumentException.
  3. When you add the "img" variable to the Items collection, you are actually adding the image itself to the collection, but the ListBox can only display strings. By default, it uses the ToString() method of any object in the collection to display on the list. This is where the "System.Drawing.Bitmap" comes from. To remedy your problem, you'll need to keep track of a separate collection (something like an ArrayList) to store the actual pictures in. When you add items to the ListBox, instead of adding the Image itself, just add the file name, and add the Image to your separate collection. Make sure that when you add and remove file names from the listbox that you do the same to the image collection, so that the item indices of both collections match up.
  4. Two words: Microsoft Bob. :)
  5. My ISP has a spam filter which I had to turn up a few notches, but now it catches a large percent of spam. The stuff that does get through, Outlook 2003 catches, so I only end up with 1 or 2 spam messages a day actually cluttering my inbox. I love it.
  6. Bucky

    Dynamic

    So long as you set the ASP.NET application to have write permissions to all subfolders of the main folder, you should be able to write to it. The person visiting the site isn't actually writing files directly to the server; they are uploading the files to your application, which in turn writes them to the server itself.
  7. Bucky

    TextColor

    Oh, well, in that case, don't use a LinkButton control. Use the Button control.
  8. TCP would definitely be the way to go in this situation. With UDP, there is a chance that messages will never be delivered, and in this case one undelivered message sounds like it could cause some trouble. UDP is generally reserved for when a few lost messages are not important, such as the constant movement of players in a multiplayer game (where many of these messages are sent per second). TCP ensures these messages get delivered safely, and if you become disconnected for whatever reason, you know instantly and can handle it. There's a nice explanation here
  9. The WebClient.UploadFile() method uploads the file through the POST headers of the request for the page. I don't know any PHP, but I know there is an easy way to access these headers on your PHP page. Find the POST header and find a way to save this byte array to your server.
  10. Click me, man!
  11. Bucky

    TextColor

    What do you mean? Do you want to change the color of the text on a button?
  12. I'd instead create a CSV (comma-separated values) file. Each line is a row of the table, and each item on the line (separated by commas) is a new cell in that row. Just loop through each row and add the values to a file, with commas in between. Excel can open up CSV files just fine. FileStream stream = new FileStream("filename.csv"); StreamWriter writer = new StreamWriter(stream); foreach (DataRow row in myDataTable.Rows) { // Loop through all rows string rowText = ""; foreach (object item in row.ItemArray) // Loop through all items rowText += item.ToString() + "," // Concatenate item and a comma rowText = rowText.SubString(0, rowText.Length - 1) // Remove trailing comma writer.WriteLine(rowText); // Write the text to the stream } writer.Close(); stream.Close(); This code is untested, so if you have any problems, ask.
  13. Where is this code in relation to the code that dynamically adds controls to the page? So, when the page loads, is the control-creation code executed before this code?
  14. Use System.Math.Round()
  15. This is exactly the scenario that XML Web Services were designed for. What you do is design the Web Service project to have classes and methods that can be accessed (they must be Public and have the WebMethodAttribute attribute). Then add a "Web reference" to the service in your Windows app; the namespace for the Web Service is added to your project and you can access the classes and methods just like any other class that's locally in your project. Read up on "XML Web Services" in MSDN; there is a lot of good info there.
  16. Okay, here's a really general overview. At design-time, add a column to your grid that contains an Edit button or an Edit link. In the EditCommand event handler of the grid, set the EditItemIndex to the item chosen to edit (e.Item.ItemIndex) and re-bind the grid. Now the row can be edited by the user when the Edit button is clicked. To actually save or discard the changes, however, you must add code in the UpdateCommand and CancelCommand event handlers. This is, as I mentioned, really general; feel free to ask specifics.
  17. Well, for multiple results you could use a loop, but in that case RegEx might be easier.
  18. You can't change the name of all the event handlers you're adding; they have to all be the same method. This is okay, because you can discern between which TextBox is firing the event by casting the sender object to a TextBox and retrieving its name. So, here's what your loop should look like: for (int x = 0; x < 3; x++) this.txtGame[x,0].Leave += new System.EventHandler(this.txtGame_Leave); And here's your event handler: private void txtGame_Leave(object sender, EventArgs e) { TextBox txt = (TextBox)sender; // Now just check the value of txt.Name to determine which textbox fired the event } You could consider setting each TextBox's Tag property to reflect the index of that TextBox within the array; that way, in the event handler, you can just retrieve the Tag to figure out which TextBox activated the event.
  19. You shouldn't have any problem with calling the Load event; it has the same parameters as a button's Click event (sender as Object, e As EventArgs). Could you tell us the error you're getting?
  20. Using [][] does not define a multidimensional array; it defines a jagged array. Perhaps the syntax you're looking for is: TextBox[,] txtGames = new TextBox[3,5];
  21. The MSDN docmentation for Double.ToString(string) makes no reference to a parameter of "C". What are you trying to do here? Also, the code is redundant because you're converting a double to a string and then back to a double again. This should be sufficient: txtTSCTax.Text = (Convert.ToDouble(txtNum1.Text) + Convert.ToDouble(txtNub2.Text)).ToString();
  22. I don't think there are any Jornadas capable of running the .NET Compact Framework becakse HP stopped making them before Pocket PC 2002 was available.
  23. Hmmm.... if you place all the days inside yet another Panel, then when you switch months you can loop through the Controls collection of that Panel and remove them all before drawing the new month.
  24. Here you go. Google really is a marvelous invention.
  25. If you wanted, you could also make the input controls Public and then access their values directly from the parent form after the modal form closes.
×
×
  • Create New...