|
I'm new to C# and trying to add a new row to my form using tableLayoutPanel using an Add button. When I click the Add Button I believe a new row is added but the previous row disappears. I've search the web and MS for help and followed their suggestions, but continue to receive the same results. Below is the code used in the click button method
private void buttonAddDebt_Click(object sender, EventArgs e)
{
// Set the GrowStyle to Add Rows.
debtTableLayoutPanel.GrowStyle = TableLayoutPanelGrowStyle.AddRows;
// Ensure the AutoSize property is set to allow for the row to be added
debtTableLayoutPanel.AutoSize = true;
// Set Row Number to Be inserted
int InsertRowNum = debtTableLayoutPanel.RowCount;
debtTableLayoutPanel.AutoScroll = true;
debtTableLayoutPanel.Visible = true;
// Increment the row count by one for the new row.
debtTableLayoutPanel.RowCount++;
// Insert new RowStyles for correspoinding new row
RowStyle newRowStyle = new RowStyle();
newRowStyle.SizeType = SizeType.Absolute;
newRowStyle.Height = 30;
debtTableLayoutPanel.RowStyles.Insert(InsertRowNum,newRowStyle);
// Add the new row
debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Absolute, 30));
// Add controls to the new row
debtTableLayoutPanel.Controls.Add(textBoxDebtAmount, 0, InsertRowNum);
debtTableLayoutPanel.Controls.Add(textBoxInterestRate, 1, InsertRowNum);
debtTableLayoutPanel.Controls.Add(listBoxDebtType, 2, InsertRowNum);
debtTableLayoutPanel.Controls.Add(listBoxCompoundingFrequency, 3, InsertRowNum);
debtTableLayoutPanel.Controls.Add(numericUpDownAmortizationPeriods, 4, InsertRowNum);
debtTableLayoutPanel.Controls.Add(listBoxPaymentFrequency, 5, InsertRowNum);
debtTableLayoutPanel.Controls.Add(listBoxPaymentType, 6, InsertRowNum);
debtTableLayoutPanel.Controls.Add(textBoxPaymentAmount, 7, InsertRowNum);
/*
this.debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 29F));
this.debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.debtTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.debtTableLayoutPanel.Size = new System.Drawing.Size(620, 27*debtTableLayoutPanel.RowCount);
*/
debtTableLayoutPanel.TabIndex++;
debtTableLayoutPanel.Visible = true;
} // end buttonAddDebt_Click
|
|
|
|
|
looking at the designer.cs file after dropping a TableLayoutPanel on a form, it produces 2 columns and 2 rows by using this code which you should be able to use as the base for your code:
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(
new System.Windows.Forms.ColumnStyle(
System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(
new System.Windows.Forms.ColumnStyle(
System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(
new System.Windows.Forms.RowStyle(
System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.RowStyles.Add(
new System.Windows.Forms.RowStyle(
System.Windows.Forms.SizeType.Percent, 50F));
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
hi evreyone
how i can make Beep in WinCE (C#) ?
thank's for any help
|
|
|
|
|
Not sure about CE, but try System.Console.Beep()
|
|
|
|
|
MSDN[^]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
using System.Runtime.InteropServices;
....
public static extern void MessageBeep(int code);
public static void MessageBeep()
{
MessageBeep(-1); // Default beep code is -1
}
|
|
|
|
|
Ok I want to make a simple tool to send a few key strokes to a background application.
I found a few examples but these will always call it to the foreground and that is a problem. cause it needs to be done all in the back ground.
Some example applications or code snippets in C# would be nice.
|
|
|
|
|
You'll need FindWindow or FindWindowEx and SendMessage or SendMessageEx both in user32.dll.
Check out http://www.pinvoke.net/[^]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
while (loadme.ReadLine() != "];")
{
frame[framenum] = loadme.ReadLine();
framenum += 1;
}
"Index was outside the bounds of the array."
how to fix this?
loadme is a StreamReader
frame is a String[]
framenum is an int
|
|
|
|
|
Most likely your array is smaller than the number of lines returned until you encounter the string "];"
Set the array size to a proper value or use a List<string> instead.
Your code looks wrong though, you're reading each line twice. This would be better:
while((line = loadme.ReadLine()) != "];")
{
AddToArray(line);
}
modified 12-Sep-18 21:01pm.
|
|
|
|
|
use List<string> to replace string[],
you doesn't to set its length, but save it use .Add methods.
if you want to use string[], you should declare its length
greater than the line count of the file. seems you are reading from a file.
Glad to discuss with you and best wishes.
|
|
|
|
|
WuJunyin wrote: if you want to use string[], you should declare its length
greater than the line count of the file.
file length varies, how do I get the length of a file in lines, not chars?
|
|
|
|
|
then use List<string> if you are use .NET Framework 2.0 or above.
use ArrayList if you are use .NET Framework 1.1
its length add dynamicly. you can use it and no warry on its length.
or you should read more informance from msdn.
Glad to discuss with you and best wishes.
|
|
|
|
|
|
you are welcome.
Glad to discuss with you and best wishes.
|
|
|
|
|
Hi,
File.ReadAllLines() does it all for you.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi
Lets think that there is a client and a server. Client wants to send three files with small sizes to the server. Server's ip address and port is static.
- Server starts listening the port and accepts all the connection attempts coming from any ip address.
- Client establishes a connection to the server. After connecting, starts to send the files.
- Server recieves the files and saves them to the hard disk.
- Client disconnects.
- Server keeps listening the port and accepts all the connection attempts coming from any ip address.
Essentially, this is what I am trying to do. I am not a starter in C# but I am not advanced too. I have designed the code but only first file out of three is recieved by server without a problem. Because client or server doesn't wait for transfer to be completed.
At the same time there can be more than one client connected to server, server should be able to recieve all the files.
Thanks in advance.
|
|
|
|
|
It's called FTP. Learn it. Live it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I know I can use FTP. But I should not use FTP because it is not secure. When you listen the network traffic with a sniffer you can easily see the username and password.
This software will be used by people and I don't want people to see the FTP login informations.
|
|
|
|
|
Can Selçik wrote: I know I can use FTP. But I should not use FTP because it is not secure. When you listen the network traffic with a sniffer you can easily see the username and password.
Really?? Google results for "Secure FTP[^]"...
|
|
|
|
|
I think you are talking about FTPS.
How can I use FTPS client in C# and is there a FTPS server for linux?
Thanks.
|
|
|
|
|
I think you're referring to SFTP[^], not FTPS.
|
|
|
|
|
Actually I am referring to FTPS not SFTP. Because SFTP is doing his job over SSH and I don't want to risk console access. I prefer using FTPS. FTPS is doing his job with using SSL for encryption.
|
|
|
|
|
Can Selçik wrote: How can I use FTPS client in C#
You can buy a library, or write the code yourself.
Can Selçik wrote: is there a FTPS server for linux?
Man, you're full of good questions today, aren't you?
I'm sure that if you took the time to use GOOGLE, you would find your answer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
When I open a page in the WebBrowser I see appear notice board:Security information
I want programmed to automatically remove this notice I do? I'm using language C #.NET
|
|
|
|