Post questions, tips, tricks, and suggestions here

This is just a post where you can post your questions, tips, tricks, suggestions, or what have you. Post these in the comments section. (They are still subject to moderation so don’t waste everyone’s time trying to post links to knock off sunglasses.)

This entry was posted in Uncategorized. Bookmark the permalink.

24 Responses to Post questions, tips, tricks, and suggestions here

  1. szulak says:

    I have write nice article about caching object in C#. You can find it here:
    Caching objects in C#

  2. Fernando says:

    This is one question, and sorry to bother you. I’m trying to develop a Radial Menu for a customer. I cannot see how to check if a point is inside a Pie.
    I appreciate any help.
    Best regards. Fernando

  3. Ello says:

    If you could do a post on winmm.dll in PInvoke.net. Specifically the timeBeginPeriod,timeSetEvent,timeKillEvent, and timeEndPeriod methods. Having a hard time understanding how to use them. Some background:

    The precision of multithreaded timers depends on the operation system, and is typically in the 10-20 ms region. If you need greater precision, you can use native interop and call the Windows multimedia timer. This has precision down to 1 ms and it is defined in winmm.dll.

  4. Ello says:

    Can you explain when I should WPF vs Windows Form?

    • RodStephens says:

      This is mostly a matter of style. WPF provides a rich set of appearances. It allows you to customize how a particular kind of control. It also includes features that let you animate properties. For example, you could make controls move or change size when the user clicks on something. You can also customize the way some controls work. For example, you can change how and where a ListBox displays its values. WPF also has a really easy-to-use media control and some nice layout controls.

      The downside is that WPF is much slower to load and modify in Visual Studio and it’s much harder to make it do the fancy things that make it desirable.

      Both use the same C# code behind the scenes. (That’s why most of the examples on the C# Helper web site are in Windows Forms. They use the same code and Windows Forms is faster and easier.)

      When I just want to get something done that works, I use Windows Forms. If I want to make something look really glitzy with lots of animation (like some of the fancier web sites), I use WPF.

      Microsoft’s original line was, “Old programs would be maintained in Windows Forms and all new development would be in WPF.” I don’t think that has happened. All of the early adopters have moved to WPF, but I think a lot of people are still using Windows Forms. In particular, if you were building a large multi-person project with lots of code behind, would suggest prototyping in Windows Forms and then porting to WPF because Windows Forms is so much easier.

      I hope that helps.

      • Ello says:

        So what your saying is that it would still be wise to learn Windows Forms?

        Thanks your feedback. Greatly appreciate it

        • RodStephens says:

          My thought is that you would ideally learn Windows Forms when you are learning C# so WPF doesn’t slow you down. Then after you have some practice with C#, you can pick up WPF.

          Also note that experience with C# will help you with C++ or Java. Windows forms may help a little, but I don’t think WPF will help you much with other languages.

  5. Ello says:

    Hey Rod,
    I was wondering if you could series on how to create a component in Windows Forms? Ive looked all over the web and could not find a good example. Im talking about non-visible components such as Timer and OpenFileDialog(any dialog really) in the toolbox.
    Thanks in advance.

  6. Anthony says:

    Hi Rod,
    Great site and excellent books you have.

    My question is – is it possible to save multiple images to a access database?
    on my Form i have 5 picture box controls, i would like to save the images in a table with ID, persons – first name, last name, using memory stream and image array. It works on single image but i can’t figure out how to save 5 images at once.

    would you have any info on doing this or a sample that can save 5 images to ACC DB, and also when ID or name is selected to display images again in picture box controls.

    Hope that makes sense.

    Thanks for any help.

  7. Anthony says:

    Hi Rod,

    Thanks for your very quick reply. Yes your working examples are great on the topic as well as reading your books as they explain more in detail than others I’ve read and tried to follow.

    Yes I agree, it’s good practice to create a folder within the exe path and copy images to it then only store image name/path inside database. I’m trying to make a small app for my daughter to keep track of her toy horse collection.

    The more i search the net, the more this question is showing up. It seems I’m not the only person trying to accomplish coding task. I did happen to come across this link, where a person posted the same question then seemed to have found his/her own solution.

    (link:) https://www.daniweb.com/programming/software-development/threads/411716/saving-multiple-pictures

    unfortunately it’s only in part and not a working sample. Is it possible to code this into a working sample with an explanation of what code is doing when it executes? as I’m only learning.

    Thanks again for your reply and your well explained samples.

  8. Anthony says:

    Hi Rod,

    Thanks for your Samples, yes your sample saves multiple images – [ONE] per record! I want to save [MANY] per record as i stated ( 5-6 images). It’s no problem as i’ve managed to accomplish my needs for the app i’m designing for my daughter utilizing the sample code and link i mentioned. Once i read it and fully understood it- it became clear and made sense, once i implemented the code into my app with a couple of adjustments it works and performs as i needed.

    thanks for your samples and your books as they helped me accomplish what i needed.

    Thanks

    • RodStephens says:

      That was what I was trying to find out. Whether you needed to save multiple images per record and whether you needed an unlimited number or a fixed number. I may try the unlimited number example to see how hard it is.

      I’m glad you got it working!

  9. Anthony says:

    Hi Rod,

    That example will help many people facing the same problem with saving many images , for the same record entry.

    I have another question. This is proving to be a challenge for me.

    String functions:
    I understand some of the string functions and methods, but i am trying to accomplish as follows –

    I have a Textbox used to input a value, a Richtextbox to display a string of text. Lets use the following for an example in the Richtextbox control….
    —————————————————————————–
    The C# Helper web site (csharphelper.com) receives thousands of visitors every day. This practical guide describes the 100 most commonly visited posts in the C# Helper library of tips, tricks, and example programs for C# developers. Some of the examples make it easier to handle common tasks that developers perform every day. Other examples deal with more problematic subjects that developers encounter only occasionally. Because those challenges are less common, developers often don’t have ready solutions. To make matters worse, coverage in general C# books is sparse or non-existent. The C# Helper Top 100 provides complete examples demonstrating 100 useful tips and techniques. Each example includes a simple, easy-to-understand explanation together with a working example program that you can download from the book’s web site
    —————————————————————————–
    How would someone code the following:
    use the Textbox control and input the number 30 to grab the 30th word inside the Richtextbox control and display it in a messagebox or label control. Using the example string inside the Richtextbox it would show the word “tips”.

    I understand IndexOf but it won’t do as above, as one would have to supply start indexOf(0, “and supply exact char position”) to make it work.

    Is this possible. Thanks for any guidance to achieve the above.

    • RodStephens says:

      One of the easier ways to do this would be to use the string class’s Split method to split the string apart at spaces. Then simply look at the 30th entry in the resulting array. (Remember that indices start at 0 so the 10th entry would have index 29.)

  10. Roger Cabo says:

    Hi Rod,

    Sorting a Convex Hull Point List clockwise would be a nice extension to your existing 2D code examples. There is one interesting example from Autodesk.

    https://forums.autodesk.com/t5/net/sorting-a-list-point-of-a-polygon-clockwise/m-p/7367684#M55128

    The class Point2d should be added by custom code without an IEnumerable, but with the required .GetDistanceTo() functionality.

    Kind regards, R.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.