How to implement search for form objects? - c#

I use c# and c++ builder, and have big application with many menus, buttons, check boxses, and also with many forms. When trying to use one of functionality of those objects I use standard user method by clicking on button, clicking on menus and choose some submenu options, etc...
But now I want to use faster method to use functionality of objects, want to create search for objects. That means if I type name of some button and press enter, that those event become same as i click on same button. I don't want to clicking on buttons, and menus anymore cause it take me too much time to find it.
So I create new form which appear on shortcut and have inside listbox that will be using for search all objects, but I don't know what code to put inside that listbox show me all object names?
How to connect listbox with all objects which is inside project?

In C#, every Control has Controls property that returns a collection of child controls. You can iterate through all the "children" of a form and add their names to your listbox. In the opposite direction, when you've got a control name, you can find it using Controls.Find() method.
For CBuilder case, refer to the following thread:
BCB : how to iterate over controls on a form?

Related

C# WinForms - How to create a Properties Page like Visual Studio Project Properties

I'm trying to create a form that operates like the Visual Studio Properties page, with a list of categories (like Application, Build, Build Events etc) in a column on the left and corresponding information on the right. I'm planning to use either panels or a tabcontrol (with the tab header hidden) for the right hand side.
However, I'm unsure how best to create the column of categories on the left. Is there a standard control that provides this functionality?
Otherwise, I considered using a panel containing Buttons, or individual Panels, or a ListBox, but I don't think these would give the same look. Also, I don't want to write code if a suitable control already exists.
Ideally I would like to be able to easily disable all the categories, for example while editing a record on one page.
Having nested categories might be nice, but is not essential.
If the information on the right is not related to one another as you switch categories on the left, to create a good separation between categories I'd suggest you do the following:
Create a user control for each individual category
Split your form in two, the bar on the left and a panel on the right
The bar on the left, for the categories, can be a list of radio buttons, or links, or whatever you like. I'd suggest a TreeView since it easily support sub-categories.
As the user click on a category (by attaching a method to the corresponding even on the control used for the categories) you can remove the control from the panel, if any, and reset the control that corresponds to the selected category.

C# How to group different Form Controls together?

I am using Windows Forms.
I do only have one Frame. In this Frame I organized some Controls together. Where the Controls in one Row belong together (they form an Object). And overall I have five of those Rows, with the same Controls.
Eg.: Name , Surname, Age, Income, etc (in one Row)
There are Dropdownlists, Checkboxes, NumicUpDown, etc
I would now need to know an way to "bind" them together. The same counts for the Events. Because at the moment I would make for every different Control an Event and then distuingish them by an Number at the end of the Controls Name, which would be rather annoying. And then generate from that the Object.
What way do I have to not make dozens of Events and indicate that everything in one Row belongs together?
For grouping them together on the Form (not Frame) - put them all on one Panel.
To use the same even handler for all of them - simply subscribe to the same one. (Using the designer - select the events, and choose from the drop down. For doing this from code - just do YourControl2.EventName += YourControl1.EventName.) Note that this is not possible for every type of Control and every event. It's only possible if the events have the same signature.
You can easily create a UserControl. Right-click the project or a folder in the project and select UserControl. You can then add controls to it, in the designer, just as for Forms.
Once you have compiled the project, your UserControl will appear at the top of the toolbox and you can drag and drop it onto a form.
Like this would would create a user control representing one row, and add one of them for each row to your form. You can also add additional properties, methods and events to your user control class. They will automatically appear in the properties window.
But in your case, a DataRepeater Control for Windows Forms would be appropriate. It is part of the Visual Basic Power Packs, but just works as well in C# projects.
take all your controlls in one Panel. So You can with group more RadioButtons and they can know one for anderer. Then you can between them scwiching so you becomming what you whant.

Is there another way to browse user controls in C#

I am new to C# and I am using windows forms.
I don't know if the term "browse" is right to use in this case or not.
I have Form1 with 3 buttons ( buttonA , buttonB and buttonc) in it.
I linked buttonA with a user control which contains 20 buttons and each one of those 20 buttons is linked to a user control which contains 10 buttons each of which does an action which it is clicked, also same thing applies to buttonB and buttonC . Now I configured user controls visibility when button clicked . For example:
Click buttonA user control1 with 20 buttons show up, click one of those 20 buttons another user control show up with 10 buttons.
What I am trying to do is something like browsing windows folders but in this way I will end up having too many user controls and it is confusing and I feel this is not the correct way of doing it. Can anyone please help me if there is another way to do taht? Thank you
What I am trying to do is: I click on
Your scenario seems to be ideal to use TreeView control. This controls displays a hierarchy of items, in your case a hierarchy of products and subprodcuts. A user of your application will be able to expand/collapse nodes as he/she want just by clicking a node. It is much more intuitive and readable than pressing buttons.
For example you can easily achieve the following icons:
You can also associate icons with nodes, change their background or foreground etc.
I think ListView control may fit your needs. It can display a lot of items in different forms (for your task consider using View.LargeIcon or View.Tile for ListView.View property). It also supports groups that may be useful for building POS system.

Winforms UI Dynamically Displaying Parts

I came across a tutorial and some example code for an audio converter. You select the format you want to convert to from a drop down, and when you do all sorts of options appear in a previously blank area, different options based on the format you choose. It's called Audio Converter .NET and is from same author as Audio CD Ripper .NET. I can't find the tutorial, but here is a screenshot.
See how on the right there is extra controls that are not on the left. I was experimenting trying to add another category. I added it to the dropdown, but am unsure how to make it so certain fields come up when it is selected.
I understand that they create those controls for those items, but I don't see how they call the correct one when the combo box selects something. I see controls are created, but if I try to duplicate the controls into another entry in the combo box they don't show up for either the new or old one I was duplicating from.
What's the best way to go about achieving something like this?
Thanks
The easiest way is to create the controls needed for every option in the dropdown inside a panel, and simply turn it's visibility property from false to true whenever it's corresponding option is selected using the combobox's SelectedIndexChanged event handler. (And don't forget to turn the current visible panel's visibility to false)

Switching between to Forms within a single window

I want to change my form 1 into form 2. I don't want it to open a new window but keep it in the same window and then be able to go back and forth when I press the Next key or back key. Is the only way to do this by Individually hiding each button and picture?
You might want to consider a different approach.
You can't change one type of form into a different type of form. The closest option would be to close or hide the first and show the second at the same location on the screen.
However, you could approach this differently. Instead of putting your buttons and logic into a form, you could place everything into two UserControl instances, and just change which user control is visible within a single form.
You can use panels, group boxes, TabControls, etc. to group common controls together. When you want to switch between different "screens", you can hide or show the group control by setting the visible property and calling BringToFront(), and it will hide/show all the controls on that group control.

Categories

Resources