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.)
-
Recent Posts
-
Recent Comments
Archives
- January 2021
- December 2020
- November 2020
- October 2020
- September 2020
- August 2020
- July 2020
- June 2020
- May 2020
- April 2020
- March 2020
- February 2020
- January 2020
- December 2019
- November 2019
- October 2019
- September 2019
- August 2019
- July 2019
- June 2019
- May 2019
- April 2019
- March 2019
- February 2019
- January 2019
- December 2018
- November 2018
- October 2018
- September 2018
- August 2018
- July 2018
- June 2018
- May 2018
- April 2018
- March 2018
- February 2018
- January 2018
- December 2017
- November 2017
- October 2017
- September 2017
- August 2017
- July 2017
- June 2017
- May 2017
- April 2017
- March 2017
- February 2017
- January 2017
- December 2016
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- March 2016
- February 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- February 2014
- January 2014
- December 2013
- October 2013
- August 2013
- June 2013
- December 2012
- September 2012
- July 2012
- June 2012
- November 2011
- May 2011
- April 2011
- February 2011
- December 2010
Categories
- .NET
- 3D
- 3D graphics
- ADO.NET
- algorithms
- animation
- API
- arrays
- attributes
- audio
- books
- C#
- C# programming
- calculations
- challenges
- classes
- clipboard
- coding
- combinatorics
- console
- controls
- cryptography
- curve fitting
- database
- debugging
- dialogs
- directories
- Drag and Drop
- drawing
- drawings
- enums
- Event
- events
- example program
- Excel
- extension methods
- extensions
- files
- finance
- fonts
- formatting
- forms
- fractals
- ftp
- games
- GDI+
- generic
- geometry
- globalization
- graphics
- html
- IDE
- image processing
- inheritance
- interfaces
- internationalization
- internet
- interoperability
- LINQ
- lists
- localization
- mathematics
- memory
- menus
- MessageBox
- methods
- miscellany
- multimedia
- network
- Office
- OOP
- operators
- parsing
- performance
- phone
- PowerPoint
- printers
- printing
- productivity
- programs
- puzzles
- recursion
- reflection
- registry
- regular expressions
- serialization
- settings
- SQL
- stories
- strings
- syntax
- system
- threading
- three-dimensional graphics
- tips
- tools
- transformations
- Uncategorized
- user interface
- variables
- VBA
- web
- Windows Forms programming
- WMI
- Word
- wpf
- XAML
- XML
Meta
I have write nice article about caching object in C#. You can find it here:
Caching objects in C#
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
See this post:
Determine which pie slice is under the mouse in C#
Thank you so much, Rod.
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.
Can you explain when I should WPF vs Windows Form?
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.
So what your saying is that it would still be wise to learn Windows Forms?
Thanks your feedback. Greatly appreciate it
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.
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.
I think my old book Custom Controls Library does that. (Holy cow! Was it really that long ago?)
I’ll see if I can post an example in the next few days.
Thanks in advance. Also good luck with the new book The Modern C# Challenge by Packt. Should be a good one 😉
See:
Make a custom component in C#
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.
See this example:
Save images in an Access database in C#
You may also want to consider saving the images in files and then saving the file names in the database. That way if there’s a problem you can work with simple text strings instead of binary data in the database. For that approach, see this example:
Use filenames stored in a database to display images in C#
Or did you mean that you want an unlimited number of pictures for each entry in the array? You can probably do that, although I don’t have an example.
You could consider using XML to serialize the images and then saving the serialization.
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.
So are you trying to save multiple picture in a single record? That example Save images in an Access database in C# shows how to save multiple images one per record and find them by selecting the records.
If that’s not what you need, I don’t understand what you have in mind. Let me know and I’m sure I can come up with an example.
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
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!
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.
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.)
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.
The example that finds a minimal bounding rectangle includes links to examples that you can use to do that:
Use the first to determine whether the polygon is already oriented clockwise. If it is not, use the second to reverse it.
I’ve just developed this for updating from a DataGridView via stored procedure
I hope someone finds it useful
Hello Rod,
Do you have any information about EnvDTE Code Model?
Ive been looking for information on this topic but could not find anything good in C#.
For what I understand its allows a programmer to use source code as data (like reflection before its compiled). If you any information on this I would greatly appreciate it.
Regards,
Ello
Hi Ello. Unfortunately I have not used this one. Sorry. 🙁
Hi Rod,
Since the beginning of August 2020, your posts have been falling off the chart.
We wonder what you are up to?
Be safe.
Sorry, I’ve just been really busy lately. I have a backlog of posts that I’ll get to eventually! 🙂
If people ask questions, I still try to answer. And that’s the best way to make me find time for a post.