|
Put a breakpoint in your code in this routine. Search through your code for all instances of the word Test and put breakpoints on them all - each and everyone. Run the program again and note each breakpoint you hit - you must be resetting the text back to Test after you have left this routine.
|
|
|
|
|
Trying that statement shouldn't even compile. Assuming you didn't complete the statement you really used (with a semi-colon,) this will normally cause the button to refresh and show "Hi" (Without quotes) like your other responder said.
You can try to force a refresh with an .Invalidate
Once, I tried to execute complex logic and print intermediate results by modifying text boxes' .Text property. Wanted to know why that wasn't working. Your winapp has to be idle and waiting for a response before it will render the changes.
I fixed that by assigning a delegate in the winapp, running the calculations on another thread and calling the delegate.
|
|
|
|
|
private void btn_Click(object sender, EventArgs e)
{
if (folder.Visible==true )
{
btn.Text = "Hi";
}
else
{
btn.Text = "By";
}
}
Make sure your property folder.Visible is change when click state
btn.Text = folder.Visible?"Hi":By;
folder.Visible=!folder.Visible; // reset state here
TU
|
|
|
|
|
Hi
I am changing the folder to visible or not visible. But nothing is helping me.
Thanks
Fia
|
|
|
|
|
Given all the responses above, clearly something very weird is happening here.
Are you talking about a standard WinForms Button object here ?
Also: what is "folder," exactly: that's an odd name for a Control. And, if "folder" has a boolean "visible" property, you can use it directly : if (folder.Visible) ...
You mention: "I don't know if it has anything to do with the problem, but I have a FileLListbox and a FolderListBox from Alva on the form. Should that be the problem."
Is "folder" by chance an "Alva" control ?
What are the "Alva" controls, and, is it possible your use of them has introduced some kind of modification that is indirectly changing the way other controls behave ?
good luck, 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
|
|
|
|
|
Hi
Thanks for all your replies. I have found my error.
I used InitializeComponent(); both in the constructor Form1() and in
Form1_Load(object sender, EventArgs e)
I am so sorry for my misstake, but know it's working as it should
Many thanks
Fia
|
|
|
|
|
Does anyone have a good reference to a site or a book that focus's on custom controls? I have watched all the youtube videos. Also I completed the training at learnvisualstudio's website.
Thanks,
TheChazm
modified 24-Jan-12 15:11pm.
|
|
|
|
|
|
|
If by "custom controls" you mean UserControls in WinForms, I have benefited greatly from Matthew MacDonald's excellent book "Pro .NET 2.0 Windows Forms and Custom Controls in C#"[^].
Yes, that's quite an old book now (2004), but the author goes into many details, such as defining custom design-time adornments, and complex Property Browser selection mechanisms for custom controls, in a way that I have found clearer than any material I have read since.
"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
|
|
|
|
|
Thank you all! This has been a huge help and I have the guidance I need. Thank you for taking the time helping a stranger 
|
|
|
|
|
hi
i need to place on my form buttons as N number
and i need that the buttons will be an array.
for example: N=5
i need to see on screen: [button1] [button2] [button3]
[button4] [button5]
how to do it on C# WinForm FW3.5
thanks in advance
modified 24-Jan-12 9:00am.
|
|
|
|
|
Assuming that you have detailed your requirements correctly, and that you can't use a list (for example), you could do it like this (in pseudocode):
declare array of size n
for count = 0, count less than n
create a new instance of button
set the text of the button
add it to the parent control collection (where parent could be a form, a panel, or the like)
end for
|
|
|
|
|
Don't forget to set the Location of the Button.
I also tend to put have a Panel or GroupBox to hold such dynamic Controls to separate them from the non-dynamic items.
|
|
|
|
|
The solution would be:
public Form1()
{
InitializeComponent();
var buttons = new Button[5];
for (int i = 1; i < buttons.Length; i++)
{
buttons[i] = new Button();
buttons[i].Text = "[button" + i + "]";
buttons[i].Location = new Point(0, 25 * i);
}
Controls.AddRange(buttons);
}
obviously you would have to adjust on your formatting. but thats the general idea. hope this helped.
|
|
|
|
|
Please note the above code would produce #4 buttons, not #5. The array element at position #0 will be undefined.
If the button's width, which you don't specify, is exactly #25, then they will be equally spaced, and not overlap; but that makes an assumption about a button's default width, which can be affected by whether 'AutoSize is 'true, and the width of the 'Text property content.
And, no, I did not down-vote your post.
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
|
|
|
|
|
I agree with your statement. This was a rough general idea so he could get started. Not a final solution. Please bare that in mind. Thanks though.
|
|
|
|
|
Hi,
simple Q,
I need to create a basic Form in google docs and send the
Form to 5000 users every month
I was wondering if it possible to send the forms through my application
and later save the results through my application as excel ?
Tanks,
|
|
|
|
|
|
can i use winform application or NT (service) to retrive the Data?
|
|
|
|
|
Well, as the link includes a .NET client version, I'd say there was a very good chance that it would.
|
|
|
|
|
|
|
how to fix the position of a scroll bar....after selecting a row in grid view....suppose if i select a last row in a grid view and trying to perform an operation....the selected row should be freezed...it should not go back to the first row in that grid view...similarly how to do in a table contents...instead of gridview.. .
|
|
|
|
|
This is what I did and it works:
You have a hidden control calls vertscrollpossition and a panel called panel_contents.
This is the code behind:
private void SetScrollPosition(){
string script;
ClientScriptManager CSManager = Page.ClientScript;
if(!CSManager.IsOnSubmitStatementRegistered(this.GetType(),"SaveScrollPosition")){
script = "var HiddenField = document.getElementById('" + vertscrollposition.ClientID + "');\n\r";
script += "var ScrollElement = document.getElementById('" + panel_contents.ClientID + "');\n\r";
script += "HiddenField.value = ScrollElement.scrollTop;\n\r";
CSManager.RegisterOnSubmitStatement(this.GetType(), "SaveScrollPosition",script);
}
if(!CSManager.IsStartupScriptRegistered(this.GetType(),"RetrieveScrollPosition")){
script = "var HiddenField = document.getElementById('" + vertscrollposition.ClientID + "');\n\r";
script += "var ScrollElement = document.getElementById('" + panel_contents.ClientID + "');\n\r";
script += "if(HiddenField.value != '')\n\r";
script += "{\n\r";
script += "ScrollElement.scrollTop = HiddenField.value;\n\r";
script += "}\n\r";
CSManager.RegisterStartupScript(this.GetType(), "RetrieveScrollPosition",script, true);
}
}
This is the aspx code:
<asp:Panel ID="panel_contents" Height="175" Width="800" runat="server" ScrollBars="Vertical" ViewStateMode="Enabled" EnableViewState="True">
</asp:Panel>
<asp:HiddenField ID="vertscrollposition" runat="server" />
V.
|
|
|
|