Curtis Rutland's Profile User Rating: *****

Reputation: 4628 Guru
Group:
Moderators
Active Posts:
8,322 (4.74 per day)
Joined:
08-June 10
Profile Views:
81,005
Last Active:
User is offline Yesterday, 08:58 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Chevrolet
Dream Kudos:
1000
Expert In:
C#, LINQ, Dynamics CRM 2011

Latest Visitors

Icon   Curtis Rutland has been promoted!

Posts I've Made

  1. In Topic: Threading issues

    Posted 25 Mar 2015

    If you're using Windows Forms, the simplest way of multitasking might be the BackgroundWorker. Tasks are great, but if you have to update the UI you have to set the synchronization context. The BackgroundWorker is designed for WinForms.
  2. In Topic: Help with exception of type 'System.FormatException'

    Posted 24 Mar 2015

    Ok, so there's a chicken-vs.-egg thing going on here.

    You want to parse the value of the TextBox as a Double. You can't do that until there's something in the TextBox to parse. The reason you're getting this error is because you're trying to parse the value before you've filled in the TextBox.

    You haven't shown us the code surrounding the one line you provided, so we don't really know when the line you've shown gets called. We can't tell you how to fix it properly, because we don't know without more information.

    My guess is that you're trying to do it in the form's constructor, or some method called from the constructor, as if this were a console application. It's not. You have to learn the concept of events. Do you want to parse the value when you click a button? Use the button's event handler. Let us know at what point should the number be retrieved from the TextBox, and we can help you out. What action should the user take to kick off the "grab the value from the textbox and convert it" process?

    Either way, we need to see the whole function that the line that has the problem is in. But in a few words, the problem is that you're trying to get the value out of the textbox before you put one in.

    double.TryParse could fix your issue, but it might not as well, if you're just calling the function too early. If you are, then all TryParse will do is suppress the error, but you still won't get a valid value out of it. It's the right way to parse the value, but if you're doing it at the wrong time, it doesn't solve your problem.
  3. In Topic: Align an integer/decimal values on the Left [devex gridview]

    Posted 24 Mar 2015

    In most spreadsheet-style grids I've used, numbers tend to align right, whereas text aligns left. See Excel or Google Sheets for example. I haven't used DevExpress controls, so I could be completely off base, but it might be that since he's using numeric data, the cells auto-right-align, like Excel.
  4. In Topic: Filling and sending a POST form using c#

    Posted 24 Mar 2015

    Since all you have are vague requirements, I'll provide some vague resources that will get you started. I'd love to know what you searched, because "C# Post Form", or "C# fill out web form" brings back tons of good results.

    The question becomes: do you want to actually load a browser, put values in the textboxes, and hit submit? Or do you want to skip the browser all together, craft an HTTP POST request, fill in the form parameters, and get the response (as text) from the server in code?

    If the first is the case, you'll be better off using a Web Load Test project, something like that. It's not the best way of doing things unless you're actually automating things for an interactive user.

    If you're just interested in getting data off the page behind the login form, the second route is much better.

    Once you know that, you can start looking at how you want to get your data. If it's simple enough to parse out, just use a WebClient or an HttpClient. If you'd like, you can craft an HttpWebRequest by hand. Or, you can look into the HTMLAgilityPack, which is a powerful HTML parsing tool for C#.

    Just search the bolded items to learn more. We can provide more help if you clarify your requirements, but please note: we will not help you scrape a site you don't own that does't allow scraping. If this is some public site where scraping is against the TOS, this thread will be closed. If the site provides an API, use that instead.
  5. In Topic: Interfaces

    Posted 24 Mar 2015

    View PostxXZexxMooreXx, on 29 December 2014 - 02:02 PM, said:

    Like delegates/events, interfaces have been another confusion topic. I'm seeing the idea of an interface concept as described, but not where it's useful. I have read where someone said that studying design patterns would help to see how they are useful.

    Regardless, thanks for the tutorial.


    I like to say that interfaces define a "can do/be" relationship, whereas class inheritance defines an "is a/an" relationship. A 2012 Prius "IS A" car (Car being an "abstract class", and Prius "is a" Car). Interfaces are a bit harder to describe that way, but imagine an "IGarbage" interface. What might you throw away? Paper, old food, ratty clothing...stuff that has nothing in common, except the ability to be thrown away. That's where interfaces shine. They don't describe a parent-child relationship, they basically say "any class that implements this interface can be treated in a similar way for these specific actions/properties".

    Let's use a real-world, .NET Framework example. IDisposable is a common interface. Have you ever used the using construct? Not the directives at the top of the page, but something like this:

    using(var sr = new StreamWriter("c:\\file.txt")) { //...
    


    The only reason we can use StreamWriter there is because it (or one of the parent classes it derives from) implements IDisposable.

    IDisposable defines just one method: Dispose. And any number of dissimilar things can be disposed of; Streams, Database connections, HTML Forms (in ASP.NET MVC Razer), unmanaged resources, etc...

    You see, there's no commonality for all these things except the ability to be disposed. That's why there's not some base class that they all implement; it wouldn't make sense. But they all can be disposed of, so it does make sense to allow us to treat them the same for that purpose only.

    So, the using statement takes an IDisposable. It treats the object as an IDisposable. The only method available to it when treated that way is Dispose, but that's all the statement is going to use anyway.

    Let's use our own example. Let's say that you want to have some common Logging in your code. You could define an interface called ILoggable. Then write a logger class that takes ILoggable items, and writes them to a Text File. You don't need to know what is being logged; just that the class has a method that will dump its contents as a string (defined in the ILoggable interface). Who cares if it's a Person, a WebPage, a Whatever. All we need to know is that it's loggable, and this is the method that will always be there to call.

    That's the true power of interfaces.

My Information

Member Title:
(╯□)╯︵ (~ .o.)~
Age:
30 years old
Birthday:
August 29, 1984
Gender:
Location:
San Antonio
Forum Leader:
C#
Full Name:
Curtis Rutland
Years Programming:
7
Programming Languages:
C# -- Forms, WPF, Silverlight, WCF

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://curtisrutland.com
Skype:
Skype  insertAlias_bytes
Twitter:
curtisrutland

Comments

  • (2 Pages)
  • +
  • 1
  • 2
  1. Photo

    NewRandomUsername Icon

    06 Jun 2014 - 20:59
    Did you get my messages(emails) sir?
  2. Photo

    BenignDesign Icon

    03 May 2013 - 13:29
    I see you were staring at my profile. I also stare randomly at profiles. We have much in common. We should probably hook up sometime. Just sayin.
  3. Photo

    eric wallace Icon

    31 Jan 2013 - 02:53
    can you help for visual basic
  4. Photo

    no2pencil Icon

    06 Dec 2012 - 08:34
    It still isn't good enough.
  5. Photo

    ikram002p Icon

    27 Jun 2012 - 10:51
    "It Doesn't Work!" That's not good enough!
    It Still Doesn't Work!.
    I didnt undestand it ??
  6. Photo

    tlhIn`toq Icon

    18 Mar 2012 - 11:22
    Congrats on breaking 3000
  7. Photo

    Curtis Rutland Icon

    08 Sep 2011 - 14:13
    "Leveling up." I like that!
  8. Photo

    MATTtheSEAHAWK Icon

    08 Sep 2011 - 13:55
    Yar ya see, i remember when yee wer purple!
    Anyways congrats! It's weird seeing people who've been one way so long "leveling up" :P.
  9. Photo

    Curtis Rutland Icon

    08 Sep 2011 - 12:59
    Thanks!
  10. Photo

    Sergio Tapia Icon

    08 Sep 2011 - 12:29
    Congrats on becoming a mod. :D
  11. Photo

    Ace26 Icon

    15 Jun 2011 - 13:39
    Hi mate, interesting to see we are age mates. Nice work you do in the forums.
    Just dropped by to say hi, anyways.
    Cheers.
  12. Photo

    RetardedGenius Icon

    20 Apr 2011 - 18:56
    Excellent C# tutorials, they've taught me a lot I didn't know. Please keep more of the good stuff coming! :D
  13. Photo

    Curtis Rutland Icon

    24 Mar 2011 - 14:55
    Yeah, felt like "professionalizing".
  14. Photo

    Dogstopper Icon

    23 Mar 2011 - 17:08
    Woah. Name switch! I took a double take...
  15. Photo

    CodingSup3rnatur@l-360 Icon

    01 Mar 2011 - 14:35
    No problem at all. Glad I could contribute :)
  • (2 Pages)
  • +
  • 1
  • 2