|
hello,
i need a help, can we replace the controls dynamically(example: replace radio button by textbox when some event has occurred), if yes then please help me in this
thank you
theanil
|
|
|
|
|
As you haven't specified what technology you are using (e.g. WinForms), I'm going to have to be fairly general here.
Yes you can. You would need to remove the controls you don't want from the parents control collection (you have to iterate over this using a for loop as you are removing items which you can't do inside a foreach if it directly affects the item being iterated). NOTE: Don't forget to dereference the eventhandlers.
Once you have removed them, add in your new controls taking care to set any relevant properties such as location, etc.
|
|
|
|
|
thank you,
but i tried that way,
i need to toggle between the controls and as the answer you said, deleting the controls every time and adding new one is time consuming, is there any alternate way to do this.
theanil
|
|
|
|
|
Rather than delete them, change their Visibility. The downside is that you will consume more memory leaving that much open.
|
|
|
|
|
i can try that thing, i am working on IEEE paper so i have to check for both time and memory.
theanil
|
|
|
|
|
Well, yes you can, but why would you ? Particurlarly in this case: it's hard for me to imagine a scenario in which a RadioButton (usually used in groups where the function desired is to select one option from many) replaces a TextBox, or, the reverse.
The second thought ... which I see Pete O'Hanlon has already explained, is to implement both controls, and "swap" them by changing their visibility.
In the case where both "alternate" controls expose the same Events (with the exact same type of EventArgs parameter), you could have, for example, a RadioButton and a TextBox use the same EventHandler for Click, although I think that, too is "dubious" practice: better, imho, they each have their own Click handler, and then call a common method if there's any code that both Click events need to use.
So, I suggest you re-consider your design here.
"Science is facts; just as houses are made of stones: so, is science made of facts. But, a pile of stones is not a house, and a collection of facts is not, necessarily, science." Henri Poincare
|
|
|
|
|
but the tables will created on runtime....
|
|
|
|
|
OK, I've read that statement and I don't really understand what you are after. Are you trying to create a database table at runtime, or are you trying to create an HTML table? What have you actually done so far?
|
|
|
|
|
Pete is right - that makes no sense.
You have to remember that we can't see your PC, or read your mind. All we have to work with is what you have told us, and so far, that is not a lot. There are so many different meanings of "Table" within computing, that we cannot tell which one you mean. The same applies for "Generate" - you need to specify clearly exactly what you are trying to achieve, and ideally how far you have got so far.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Nice requirements !
No memory stick has been harmed during establishment of this signature.
|
|
|
|
|
for (int i=1; i<10; i++) {
outp("table of "+i);
for(int j=1; j<10; j++) {
int k=j*i;
outp(" "+j+" * "+i+" = "+k);
}
outp("");
}
is runtime
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
posixtively awesome!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
For a database table, you will need to create a DDL query to create the table, and then some Insert statements to put autogenerated number values into the table.
|
|
|
|
|
My son needed to create a table of some numbers for some homework this week, so I wrote a small WinForms app to do it. Here's a snippet:
private void DisplayTable()
{
int rows = (int) this.numericUpDown1.Value ;
System.Text.StringBuilder html = new System.Text.StringBuilder() ;
html.AppendFormat ("<html><head><title>{0}</title></head><body><table cols='{1}' width='100%' border='1'><tr><th>Row</th>" ,
this.textBox2.Text , this.columns.Count + 1 ) ;
for ( int c = 0 ; c < this.columns.Count ; c++ )
{
html.AppendFormat ( "<th>{0}</th>" , this.columns [ c ].Item1 ) ;
}
html.Append ( "<th>Total</th></tr>" ) ;
for ( int r = 1 ; r <= rows ; r++ )
{
html.AppendFormat ( "<tr><td>{0}</td>" , r ) ;
int tot = 0 ;
for ( int c = 0 ; c < this.columns.Count ; c++ )
{
int val = this.columns [ c ].Item2 * r ;
html.AppendFormat ( "<td>{0}</td>" , val ) ;
tot += val ;
}
html.AppendFormat ( "<td>{0}</td></tr>" , tot ) ;
}
html.Append ( "</table></body></html>" ) ;
this.webBrowser1.DocumentText = html.ToString() ;
}
P.S. I also have apps that generate DataTable s.
modified 25-Jan-12 11:06am.
|
|
|
|
|
PIEBALDconsult wrote: My son needed to create
PIEBALDconsult wrote: so I wrote
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Disturbingly for him, he only got a C-.
|
|
|
|
|
There was no requirement as to how to create the table, I assumed that using a computer program to do so was OK. As I didn't feel like teaching him Excel, I wrote a program that would allow him to create the table.
Furthermore, he had completed his ilegible hand-drawn table before I finished with the program anyway.
|
|
|
|
|
Yeah - but it was a woodwork class...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Well, I voted this response up, simply because I like the warm feeling of thinking about a father helping his son to code.
Depending on the age of his son, and the nature of the class, and the teacher's qualifications, and what his peers may, or may not, know, about .NET, or C#: what happens when the teacher asks him to explain his solution to the class, though
best, Bill
"Science is facts; just as houses are made of stones: so, is science made of facts. But, a pile of stones is not a house, and a collection of facts is not, necessarily, science." Henri Poincare
|
|
|
|
|
It was a math class, he simply had to produce and use a table with some numbers in it to get some values to answer a few questions. The table was only an aid to answering the questions, not the answer itself. He didn't need to code, but I had hoped that he might see how having such a useful skill could benefit him.
|
|
|
|
|
I am a beginner in asp. I have a link like some thing like this http://www.mysite.com/default1.asp?id="9" . I need to change this url into like this href="http://www.mysite.com/ar/default1.asp?id="9" on a clicking a button. Means on clicking this button it will get change the url "/ar/" and the next click it will remove "/ar/" . Please some one help me to do this.
|
|
|
|
|
You might get better responses if you post this in the ASP.NET forum.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
i need to find a "Outlook Task" with a special UserProperty like "id". I know how to find a contact with this property, but this doesn't work with a task.
Contactitem:
Outlook.ContactItem contact = (Outlook.ContactItem)contactItems.Find(String.Format("[Email1Address]='{0}' and " + "[User3]='{1}'", mail_s, master_s));
I need Help please! Thank's a lot
regards
ww
|
|
|
|
|
Hi
When I could change the text at runtime, I think the property was called Capture.
How do you do in Visual Studio 2010?
If I set the button btn's property Text to "By" and try the below
btn.Text="Hi"
nothing happens.
How do I do it nowadays
Many Thanks
Fia
|
|
|
|
|
What do you mean, "Nothing Happens".
If "btn" is a control on your form or webpage(depending on your solution type), then this will change the text shown on the button.
I think that you have not given us a clear picture of your issue. Could you describe it a little more?
I wasn't, now I am, then I won't be anymore.
|
|
|
|