I'm developing an C# .NET Windows Form application that 'll manage a hierarchical tree-view structure. (I have a single SQL table with a hierarchyid column. The data set is small ~300 rows/nodes at the moment, but is bound to grow large eventually)
After I exit the application, I want to be able to restart it with the last modified state. I understand I can do this by serializing it to XML.
However, I'm trying to find a method by which the treeview could be generated directly from the table at run time, using the hierarchy id column.
After Googling around, I've found some others who wish to the same, but unfortunately I've found no solutions. Is there a good way to do this?
Thanks.
Look for IHierarchicalEnumerable, HierarchicalDataSourceControl and HierarchicalDataSourceView. Thats exactly what are you looking for.
Related
I have been looking for a while now for a way to do this but nothing seems to be what I am looking for, but all I want is to enter in some data into a DataGridView, save it and then if I want, later load it back up. All the tutorial seem to focus on log in data from some database or something like that when all I want is a grid where I can put things in and add a search filter tool so I can look things up. It is for a project I am doing and I was wanting a way to save and organise data efficiently like how you can as if it was a text document but in a grid with a search filter as well as the way you can send file over to someone else who has the application and read the data. Sorry if I have put it in a confusing way.
I am doing this in Visual Studio 2019 in C#
You could use this one as a staring point. Although such approaches seem to be outdated. (Using datatables etc) Your best bet is using classes for serializing the data to json and sending the json file
i am working on c# win form project that stores name,phone No into XML file and display all data back to data grid view. File size is increasing day by day , I need this data multiple times on different forms, and parsing XML file every time is very costly. i would like to load XML file once and then use it where ever i need in my application but i do not know how can i perform this methodology in my project. Kindly guide me about best Approach for this problem.
Caching the parsed XML till it is needed is a solution to this.
Caching is a concept of storing the data in a Cache of the webserver for easy access if the data is being used multiple times, since querying the database each time would be laggy.
You can use the cached data instead of Querying the database each time you need something.
if you already have the XML parsed once, you can store it as a cached variable.
Look at this Question Here. It explains how exactly caching texhnique is used.
Hope this helps....
Thank you!
I am currently working on a feature in my project that should fulfill the following function:
- the user can browse for an excel file (with as much as 65.000 rows)
- my tool should then somehow (not so important how as long as it's more or less efficient) populate a datagrid with that data.
- the tool should then modify the table in several ways and at last the user can select several rows that will be stored to a database.
I have already tried:
- using Interop, but going through all the rows in the Excel file and displaying them in the datagrid alone took more than 10 minutes
- creating a SSIS package in SQL Server Management Studio, which was much faster (just a few seconds). However, I haven't found a way to use that in my WPF application. Plus I'd need to add at least one column via code-behind (again, I don't know how to do that) which contains a reference ID.
I know my 'question' is very vague, but I really don't know what I should look for. I hope some of you have already done something similar and can tell me how they did it or how they would do it.
Cheers
I have found a way.
I converted the Excel file into cvs, used a StreamReader and read the lines into a DataTable as plain text.
Then I went over that DataTable, created Objects that I then added to an Observable Collection.
It takes less than 3 seconds :)
Thanks for the comments
I'm trying to design my C# winform application with a very generalized function to automatically go through all of the form elements and save their states/values in a text file so that I can load it later. I want it to be very generalized so that it'll be a cinch to reuse this code in future projects, as it wouldn't be heavily tied down to the specifics.
The form elements I want to save are text boxes, combo boxes, data grid views, list boxes and that's about it. I want to save their values and everything about them.
One way that I was going about it was to go through every possible form element and then detect eachs type, and then create the corresponding c# code to re-create its value ('tboxmine.value="blue elephant"'), and then writing the code to a file, so that I could load the code from the file and execute it using the CSCcompiler. My code so far doesn't seem to be working correctly and I'm having my doubts that this compiler is actually running the code inside my application (I think it's possibly creating a new thread?), and it just seems like there's probably a far more straightforward relatively standard way of doing this.
This seems a bit like the reverse "best practice" approach. If you dont't know about databinding I suggest you look into that.
Basically you create classes to represent your data and use databinding to associate controls with your objects. The controls will automatically show the right value and allow the user to change it. If the user has changed the value, your object gets automatically updated.
To save the data, you would use some kind of serialization to store your objects in a file. When loading, you let the Serializer rebuilt your class structure and (best case) you are good to go.
This is not exactly what you asked for, but I think it is something you could use well ;-)
N.B.: Not the complete state of the control is saved. e.g. in a Textbox your text would be saved but the BackColor won't.
To get you started look into this tutorial: http://www.codeproject.com/Articles/24656/A-Detailed-Data-Binding-Tutorial
I'm working on a web app in ASP.NET MVC 3 using the Razor HTML 5 engine and C#. The client wants something pretty complex and I would like to know if there is any examples out on the web that might show me how to begin setting this up. Here's what they are looking for:
I have a very large SQL database (25,000 rows). They want to be able to select the data using three different views on the same page.
The first will be a tree and using similarities in certain columns of the table will be how the tree is broken in to sections.
The second will be a grid. This will be just one entire list of the everything in the database that you can scroll through. Of course there has to be some sort of virtual scrolling because loading 25,000 rows rather quickly isn't going to happen.
The third will be a search box where you can type in the code and select it that way.
All three of these need to be linked so that when you type a code in the search box it will select it in the grid and in the tree. If you select it in the tree then it will be selected in the grid, and if you select it in the grid then it will be selected in the tree.
They also want me to remember the last selection when you navigate away and be able to type a code n on a different page and go directly to this page with the item you typed selected. Therefore, I need to be able to use MVC's capabilities to establish a hyper link for every item in the list (I assume that would be the way to do this)
This is honestly the first time I've worked with ASP.net MVC and I feel like I may have bitten off more than I can chew with this project so any help would be greatly appreciated!
They would rather it if I didn't need to include any extra dll's so if there is a way to do this without third party tools that would be even better, but at this point I'm just looking for anything.
A few random ideas/thoughts about this:
This is kind of a big project as your first MVC app - hopefully you have some experience with HTML/Javascript/jQuery since it's going to require a fair amount of glue code to make everything work together. There is no "here, do this" solution.
There are a bunch of different free/open source projects for treeviews and grids. I've used jqGrid for a number of projects - it works well. It has a decent API and is fairly configurable (although it may take some digging to find the example code you need).
For a treeview, you can try jsTree. I haven't worked with it, though.
I'd suggest starting with just the treeview, or just the grid and get it working first. Then add the other control and get it working. Then add the search. Finally, I'd work on getting everything to work together.
To handle navigating to a specific selection, you can pull information off the query string from Javascript.
Realize that most of this is going to be happening in Javascript on the client side, not much server side.