Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey everyone,

I am working on a code snippet manager, and I am going to use a listview control to store all of the different programming languages, and then under the main language have different code snippets that can be used. So for example if the main programming language is C# it would be like this:

C#
Save File
Open File
C++
Save File
Open File

That is just an example, but that is what I want it to happen. My question is, how do I make an item in a listview which would make it look like that? I can't find the answer anywhere and I have never used a listview before! My other question is, how would I store the code snippet with the title so that it shows up like that? I also want to add a functionality where the user can add their own code snippet to it. But I am unsure of that too.

Is there any other way of doing this that would work the same way? I want it to all connect to a database, so if one person adds the snippet other people can see it as well. Or if the user doesn't want it like that, then it will be held personal. Any type of help will help. I am using C# WinForms on .NET 4.0.

Thanks guys!
Posted

I'd use a TreeView to represent the snippet categories (root nodes) and the snippets (and maybe (later) folders?). Then create a class to represent you snippet (the actual snippet string and additional metainformation (if you deal only with "real" snippets you could even read the metainfo out of the snippets (xml-parsing). You can implement this class for yourself and "map" it to database entries, or you could use a OR-Mapper like LinqToSql or EntityFramework to generate the classes if you prefer model or database first approach. This should just give you some hints to start...
 
Share this answer
 
Please see my recent answer: How do I remove this character '_' in ListBox[^].

—SA
 
Share this answer
 
Sergey,

That doesn't seem to be what I was asking, I am sorry for the confusion!

johannesnestler,

You say to map it to a database, is there any good articles you recommend for that?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900