Dynamically creating user inputs - c#

I'm programming in C# with Windows Visual C# 2010 Express.
My goal is to create a form that shows a single row of Textbox inputs at initialization, but after the information has been filled out, have the program create a second row to allow for the user to enter another row of information. I also don't know the limit to how many of these rows will be needed, hence the hope to dynamically create them. I want this program to be versatile enough to create an infinite (sort of) number of TextBoxes/Buttons/Labels/etc.
Everything that I've seen so far is web-based (C# in ASP.Net). I want to make a program that has this functionality instead. Any thoughts or insights? I don't know if this is possible.

Use a DataGridView with a TextBoxColumn and use a BindingSource to attach it to a List<string>.

Related

Change DataGridView connection and query on another form based on selection c#

I've been trying to find an answer for this and I'm completely lost.
I have an application that starts with a logon screen, after the client is logged on, it opens an MDI Form in which I have some items on a menu strip. One of them are assets (which is what the app will be used for), and the assets menu has a drop down with different assets to select, PC's, software etc.
When you click on PC's, another window opens within the MDI Form that has a DataGridView on it. And it works great but, I don't want to create a window for each and every connection or table in my databases, I feel this is bad practice.
So what I want is, to be able to change the DGV based on the asset selection, but for the life of me I can't figure out how to do this. I've been trying to pass parameters from one form to the other but the I just get different errors etc.
Can you guys please point me in the right direction? I am new to visual studio etc and want to learn these things, so I'm not asking for freebies so to speak, just what the logic should look like more or less.
Thanx!!
I don't have code for what I'm trying to do because I have no idea what the logic should look like.
I'm still trying wrap my head around how two forms communicate in a way I need.
I'm used having variables in a loop and when they change values the result changes. But in visual studio everything needs to be called which makes it a bit difficult for a rookie like me.
I did try sending sql commands via variables, but read that, that is a very bad idea.
I just want the DGV to change the data its showing based on a button selection.

Visual Studio - Modular control groups in a Form

In my project I have the need to create a Form with 16 identical replicas of the same controls. So far I've managed to do this by just copying and pasting the controls and renaming them one by one, however this is becoming really inefficient and I feel like there must be a better method to handle this situation.
Down below there is an example of what I'm talking about: every line has the same controls that are handled exactly the same, have the same Items and only interact with each other within the same line.
Is there a way to create a modular group of controls that I can replicate and handle with a simple incremental index? The best would be if modifiying the original one would affect every copy of it!
I'm using Visual Studio Express 2013 for Windows Desktop and C# as programming language.
This kind of data calls for a DataGridView Control. It supports text, checkbox and combobox "out of the box", and you can add support for Numeric Up/Down Cell as described here: https://msdn.microsoft.com/en-us/library/aa730881%28v=vs.80%29.aspx
Creating a custom control as Johnny Mopp suggested (in the comments) was the best solution for my problem.

VSTO AddIn Form Showing a Dictionary

I want to display a dictionary on a form in an Outlook 2013 AddIn with VSTO in C#.
Actually I want to display two dictionaries, maybe a large dialog with 2 listbox or something to list the key value pairs, or two tabs each with a listbox or something to display one dict and one tab to display the other dict.
Anyone know the best way to accomplish this? I've tried all the methods I found online and none seem to work. I'm a bit stuck. Anyone know a good way to take achieve this? The dictionaries are created during the AddIn startup within the OutlookRibbon class. I can make them accessible from the outside if need be by making public properties if needed or just make the variables public.
This isn't part of my question, but I want to eventually perform CRUD operations on the dictionaries. If there is a better way to accomplish this than a form with buttons that will manually perform the operatins, I'm all ears. I am not using a database, this is a small addin and I need these dicts to be stored somewhere local and small. They have about 15-25 entries each so they are not big.
Any advice and short examples would be much appreciated and a huge help.
Thanks
I want to display a dictionary on a form in an Outlook 2013 AddIn with VSTO in C#.
I'd suggest using Outlook form regions in that case. See Creating Outlook Form Regions in MSDN for more information. It is up to you which controls to use on the form (depends on the business logic). .Net framework allows to use a lot of third party controls.
They have about 15-25 entries each so they are not big.
If you don't plan to store a huge amount of entries you may consider storing them in JSON or XML files.

Replacement for Index in .NET

I've been out of doing proper programming for sometime, so as an exercise in trying to get some practice, I'm trying to make a program to solve Sudoku in C# (VS 2010)
My problem occurs when I'm trying to create some form of initial grid for the data out of text boxes. Back when I used to use VB6, I could call all text boxes as a single name and then give them all an index number which would allow me to refer to a specific text box when I was in a loop.
As far as I can see, there's no easily visible equivalent in C# and my searching has been to no avail although I can't imagine it'd be a feature that would be removed.
Thanks in advance
You can create a control array.
http://www.devasp.net/net/articles/display/674.html
It would probably be easier, and look better, if you use a genuine grid control like the DataGridView.
One bit of bad news. In the days of VB4,5,6 Microsoft used to release a new grid control with every version of Visual Basic, which was annoying (unless you rewrote your code every year). Well, they are still at it.

Fast way to code forms in C# which is bind to SQL data

I am coming from MS-ACESS world and their programing habits, There was nice utility to make form from table, You can simply hit right click on table and make form for it. Now I looking for something similar for Visual Studio and WinForms. I am trying to develop simple application for which I need to have more then 30 forms for handling data, till now I designed database tables, keys and sprocs in SQL2008 and before I start coding forms for handling data, I asking You for main guidelines how to save my time while coding forms.
Click in VS2008 within the menu bar on Data - Show Data Sources.
In the new window you can select the first icon in the top left to create a new dataSource by help from a wizard.
Just step through it and select the database, tables, views, etc. you like.
When you're finished in the wizard, you can drag and drop the tables from the Data Sources window onto your form. You can also before drag and drop something click on the icon next to the table, view, etc. and change the container type which should be auto-generated.
Starting with these tips it should be quite easy to get a first version to run.
Last but not least:
These wizards create normal code files, which can be viewed and editing like any self written code file. So you can also take a look there to find out which base classes are needed to get all these thing to work to know how you can do some special task manually on yourself.
a simple way is to use a typed dataset (generated by vs) and to bind that to a datagridview.

Categories