|
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...
|
|
|
|
|
Hi,
can anyone guide plz..
I want to save the sqlConnection parameters in an encrypted file so the WinForm application will read the host, database, user name, and password from that file.. The file will be distributed with the application..
Regards,
jkassim
|
|
|
|
|
Just store it in your app.config file in the ConnectionStrings section. You can then encrypt this section, using techniques discussed here[^].
|
|
|
|
|
You beat me to it
(I refreshed the page before submitting my answer)
|
|
|
|
|
i get an issue with changing datagridviewbutton text per row
read alot but no suffient answer
can anybody help me ?
thanks
|
|
|
|
|
Mr.Kode wrote: i get an issue
But you don't want to tell us what it is?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
hi
I don't know haw can I open resources declared in other files in the main xaml.
I created another xaml file name PageOption where I declare all the elements I need in the page options page.
How do I open this page when I click on the Options menu item.
I am interested in a xaml solution, or just how to open the page in the event onClickOptionMenu handler function.
incomplete xaml:
<Window x:Class="georgeAlpha.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="320" Width="625">
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" WindowTitle="DockPanel Sample">
<DockPanel LastChildFill="True">
<Border Height="30" BorderBrush="Black" BorderThickness="1" DockPanel.Dock="Top">
<Menu Name="menu1">
<MenuItem Header="_File" HorizontalAlignment="Left">
</MenuItem>
<MenuItem Header="_SaveAs" />
<MenuItem Header="_Options" HorizontalAlignment="Left">
</MenuItem>
modified 23-Jan-12 11:47am.
|
|
|
|
|
Typically your View (XAML) will inform a ViewModel, via the click event, to invoke the Options object.
If you think that's bleak and cheerless, too bad. Reality doesn't owe us comfort. - Richard Dawkins
|
|
|
|