|
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.
|
|
|
|
|
Have you tried setting MaintainScrollPositionOnPostback="true" on your page? If that works, that would be the easiest to do.
|
|
|
|
|
Hi,
I am trying to connect to mySql using C# but getting this error:
Quote: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I have added the port thinking it could solve the issue! but still the same.. here is my connection string:
<add name="SQLdb" connectionString="server=192.168.0.1;port=3306;User Id=root;password=Mxjxaxax0x1;Persist Security Info=True;database=cure"
providerName="MySql.Data.MySqlClient" />
please help...
|
|
|
|
|
The answer is bound to be here
|
|
|
|
|
Thanks BUT
now this is my connection in the App.config:
<add name="SQLdb"connectionString="server=192.168.0.1;port=3306;Uid=root;Pwd=xxxxxxxxx;database=cure;" providerName="MySql.Data.MySqlClient" />
but I am still getting:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
just one notes:
The same code is working if I run the application on the server itself (using IP not localhost)
|
|
|
|
|
What happens if you try to connect to the database using a standard MySQL client? It almost looks like a firewall may be blocking your connection.
|
|
|
|
|
it works when I connect using mySQL client
but the good news..
I figured out the problem...
I just address connection timeout=120
it seems like it's taking time to connect!
anyhow..
thanks...
|
|
|
|