Dynamically adding a textbox to a panel on button click - c#

I just don't understand how this is done. I've gone through several questions here and from a few other websites.
Basically, a company will be adding process steps, and I want there to be a textbox with a button next to it that reads "Add another step." Once clicked, a new textbox will appear beneath the current one, and the button will be moved next to the new text box. What do I need to do?

Well things will get a little more complex once you ask how to maintain ViewState. However, since you didn't ask that (yet), the simple answer is just that on button click event you should instantiate a new TextBox and Insert it into the Controls before the Button.

Okay, finally found an answer I can understand. Using listviews seems to be a good way to go. I found this website
http://geekswithblogs.net/QuandaryPhase/archive/2008/10/19/asp.net-alternatives-to-dynamic-controls---part-1.aspx
And I got the results I wanted.

Related

Radio buttons, each when clicked displays two buttons, on and off

I have a set of sixteen radio buttons. When i press a radio button, i want two buttons to appear (on/off). and when i press any button, a function executes(i have no problem with this),;
when i go to the next random radio button and press it, the same thing should happen., but when i go back to the previous radio button that i pressed, it should still show the action that was carried out(i.e either on/off). It should retain the action carried out on it forever, until manually changed.\
all i need is the demonstration of the above in code for at least 3 buttons, and i will figure out the rest myself....
thanks
Use a trigger in the XAML, it is fairly simple..
http://msdn.microsoft.com/en-us/library/system.windows.datatrigger.aspx
So basically you would use the checkbox value of the original to either show or hide (the property in the style to modify) the others.
If XAML is not your cup of tea and you wish to use codebehind (really personal choice) this may help you.. I am not a WPF/MVVM stickler by any means (some duct tape helps now and then) but putting all sorts of events like this in the codebehind can get messy..
http://www.codeproject.com/Articles/28959/Introduction-to-Attached-Behaviors-in-WPF
This should be a relatively simple javascript item you need to do. Ensuring that you have ids for each of the items then make all the changes on the page and then on the final postback you will have all the correct values

Optimizing of winforms

I have a program that loads a tab that has roughly 332 text boxes it loads. When loading a new tab there is a 2-3 second delay before the tab can be displayed. I have tried to suspend and resume and even looked into threading but found out that a winform can only use one thread.
I was wondering if there was a way to create the text boxes in another thread and then add them into the main form or a way to better create 332 text boxes.
thanks for your help.
Depending on your layout, I'd strongly recommend replacing the textboxes with a DataGridView, or otherwise loading the textboxes on scroll with some kind of continous-control .
The main bottle neck is the creation of handles. In winforms, each control gets its own handle (even labels), and when used in large numbers such as this, can indeed give performance problems.
If a datagridview is not an option, can you give some more information on the layout (a screenshot perhaps?), so the community can have a go at alternatives. Creating the textboxes in another thread will create problems when you try to add them, but you could create them only when needed.
Simple: don't use 300 text boxes. You can only use one text box at a time. The rest of the data you can just draw, and when the user wants to edit it you create the edit control for it. This is exactly how a grid works, so I recommend using a grid or similar control.
I also had this problem, and it goes further to affect initialisation code for controls on tabs that has not get activated before.
My workaround is to block the program with a "loading..." splash and programatically click the tabs so that the controls get loaded/activated. Once this is done, the tabpage shoud not take as long to display again.
Although I agree with others in that you may want to look into reducing the number of controls in a single tab.

<asp:Button> not work properly : the action effect not run every once i press the button with my simple search?

I have long table with a lot of cells
i make simple to find the specific cell and make it's background yellow like highlighting
The code is ok but when i press the search button once go to the searched cell and once after 2 times go to the searched cell .. i don't know what affect on the button action
the code is long i was hope to attach it but i will cope it here in the following:
// ***** my asp
http://www.mediafire.com/file/hsgvjgv838gffq5/Compaines.aspx
// ***** the c# file
http://www.mediafire.com/file/w980kd4desbaxd7/Compaines.aspx.cs
I hope any one can solve give me why that happen
I've had asp button posting issues in grids before, just for kicks, replace it with a linkbutton and see if it works...

Selecting contents of Label Control

I have what I consider to be a pretty unique problem here, and no idea how to implement. From what I've seen, there is no documentation, tutorials, samples and/or articles on this. I've spent weeks researching, with nothing to show.
The problem:
I need the user to be able to select the contents of a Label Control at runtime, and edit it.
If this can be done by extending the existing Label control, great! Or, if this requires a whole new Label Control to be created, fine. So be it.
Using a TextBox is not an option I'm afraid.
Any help at all is greatly appreciated!
Thank you,
jase
If it's just because a look & feel issue you can make a TextBox control look the same as a label would looks like (just guessing since I can't imagine any reason for not using a TextBox).
Could you pop up a window with a text box in it and then have them edit it there, then set the text property of the label based on the edited text box or do you need to edit it in place? You can set the label text at runtime, but for user input you will have to use a text box.

C# dropdownmenuitem clicked and listview editing

I have 2 questions concerning C#.
1) I have a dropdown menu with several items in them. They are clickable, but when I click one, the older clicked one stays selected. Click another and the 2 original ones stay selected, and so on. I don't want this. What I want is that when I click one of the dropdownitems, that one is that selected one and the others are not.
2) I have a listview items on a winform. I loaded some string elements into it from a file. Now what I want to do is to be able to edit those strings and even add strings, just by clicking on the rows in which the data goes.
I've checked google and MSDN for these problems, but nothing helps, so I turn here.
2) The ListView does not support that type of action. You can roll your own (pain in the #$$), or perhaps a DataGrid would be better suited to your purpose.
EDIT:
This link may help
This one too
For #1 I'm a little confused. If the DropDownStyle isn't set to simple something strange is occuring. It's not much but maybe you could try recreating the control.
For #2 the easiest solution I can think of is to set a TextBox to be equal to the selected text value from your listview. After that write a little function to update the selected index of the listview with the edited text from the listview.
Please comment if you have any more information about #1.

Categories

Resources