Hello all,
I have a loop and would like to create a new textbox on each iteration of
the loop. The code below only generates one textbox no matter how many times
the loop loops! Any insight would be greatly appreciated.
int over = 25;
int down = 0;
for (int i = theEmail.Attach ments.Count; i > 0; i--)
{
try
{
OL.Attachment attachment =theEmail.Attac hments;
string fileStorage=@"c :\" +theEmail.Attac hments.DisplayN ame;
rmaxOutlook.att achmentFormBuil der newAttachTextFi eld=new
attachmentFormB uilder(attachme nt.DisplayName, fileStorage,i);
TextBox newTxtAttachFie ld = new TextBox();
newTxtAttachFie ld.Width = 338;
newTxtAttachFie ld.Location = new Point(over, down + 25);
newTxtAttachFie ld.Text = attachment.Disp layName;
this.Controls.A dd(newTxtAttach Field);
attachment.Save AsFile(@"c:\" + theEmail.Attach ments.DisplayNa me);
}
catch (Exception exc)
{
System.Windows. Forms.MessageBo x.Show(exc.ToSt ring());
}
} 2 1838
With non-esential code stripped out:
int over = 25;
int down = 0;
for (int i = 10; i > 0; i--)
{
try
{
TextBox newTxtAttachFie ld = new TextBox();
newTxtAttachFie ld.Width = 338;
newTxtAttachFie ld.Location = new Point(over, down + 25);
down+=25;
newTxtAttachFie ld.Text = "box"+i.ToStrin g() ;
newTxtAttachFie ld.Name ="Textbox"+i.To String();
this.Controls.A dd(newTxtAttach Field);
}
catch (Exception exc)
{
System.Windows. Forms.MessageBo x.Show(exc.ToSt ring());
}
}
--Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Mike Mac" wrote: Hello all,
I have a loop and would like to create a new textbox on each iteration of the loop. The code below only generates one textbox no matter how many times the loop loops! Any insight would be greatly appreciated.
int over = 25; int down = 0; for (int i = theEmail.Attach ments.Count; i > 0; i--) { try { OL.Attachment attachment =theEmail.Attac hments;
string fileStorage=@"c :\" +theEmail.Attac hments.DisplayN ame;
rmaxOutlook.att achmentFormBuil der newAttachTextFi eld=new attachmentFormB uilder(attachme nt.DisplayName, fileStorage,i);
TextBox newTxtAttachFie ld = new TextBox(); newTxtAttachFie ld.Width = 338; newTxtAttachFie ld.Location = new Point(over, down + 25); newTxtAttachFie ld.Text = attachment.Disp layName; this.Controls.A dd(newTxtAttach Field); attachment.Save AsFile(@"c:\" + theEmail.Attach ments.DisplayNa me); }
catch (Exception exc) { System.Windows. Forms.MessageBo x.Show(exc.ToSt ring()); } }
You never change the variable "down", so you're creating several textboxes
on top of each other. Try "down += 25" instead of "down + 25"
"Mike Mac" <Mike Ma*@discussions .microsoft.com> wrote in message
news:B3******** *************** ***********@mic rosoft.com... Hello all,
I have a loop and would like to create a new textbox on each iteration of the loop. The code below only generates one textbox no matter how many times the loop loops! Any insight would be greatly appreciated.
int over = 25; int down = 0; for (int i = theEmail.Attach ments.Count; i > 0; i--) { try { OL.Attachment attachment =theEmail.Attac hments;
string fileStorage=@"c :\" +theEmail.Attac hments.DisplayN ame;
rmaxOutlook.att achmentFormBuil der newAttachTextFi eld=new attachmentFormB uilder(attachme nt.DisplayName, fileStorage,i);
TextBox newTxtAttachFie ld = new TextBox(); newTxtAttachFie ld.Width = 338; newTxtAttachFie ld.Location = new Point(over, down + 25); newTxtAttachFie ld.Text = attachment.Disp layName; this.Controls.A dd(newTxtAttach Field); attachment.Save AsFile(@"c:\" + theEmail.Attach ments.DisplayNa me); }
catch (Exception exc) { System.Windows. Forms.MessageBo x.Show(exc.ToSt ring()); } } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rudolf Bargholz |
last post by:
Hi ,
I have the following tables
-------------
PAX:
Id
Order_Id
Name
Position
|
by: Jeff Rodriguez |
last post by:
Main just loops over this while it's not null. The segfault occurs at
this line:
*line = (char)ch;
Also, please don't just fix the code. I would like to know why exactly
this isn't working so I can avoid problems with it in the future.
If there are any references I should check out let me know.
Full highlighted code at:
|
by: SamIAm |
last post by:
Hi am creating a email application that needs to mail out a very large
amount of emails. I have created a multithreaded c# application that using
message queuing. I have created a threadpool of 5 threads and each thread
checks the queue, receives the message and sends an email. How do I
determine the right amount of threads to create?
Thanks,
S
|
by: Cor |
last post by:
Hi,
I start a new thread about a discussion from yesterday (or for some of us
this morning). It was a not so nice discussion about dynamically removing
controls from a panel or what ever.
It started by an example from me, that was far from complete and with typing
errors, but basically it had the meaning to show that removing controls
reversible was the nicest method.
This was a lets say conclusion (but what is that in a newsgroup) in a...
|
by: Jimakos Bilakis |
last post by:
Hi everyone!
I want to create a function that it will take as parameters a table
(float), an integer (the number of Table's rows) and it will re-arrange
the elements in the table from the smallest value to the biggest one. I
know it's very simple but something is missing from my code... Untill
now i manage to create something like this:
1. void FunctionReArrange (float Table, int TableRows)
2. {
| |
by: Matt |
last post by:
Hi all,
I'm trying to create a system where it reads a number of records from
a database and then creates a row in the GUI that contains a single
field from the database and a button that has a reference to the
record. This way, once the task has been accomplished, the button can
be pressed next to the field and a time-stamp is placed into the
database.
Can anyone point me in the direction of either a tutorial or
|
by: =?Utf-8?B?U2l2?= |
last post by:
I have a form that I programmatically generate some check boxes and labels on.
Later on when I want to draw the form with different data I want to clear
the previously created items and then put some new ones on.
In my code I am doing the following:
For Each ctrl In tpMain.Controls
If TypeOf (ctrl) Is CheckBox Then
If ctrl.Name.StartsWith("chkS") Then
ctrl.Visible = False
|
by: greyseal96 |
last post by:
Hi,
I am a pretty new programmer, so I apologize in andvance if this is a dumb question...
In a book that I'm reading to learn C#, it says that when using a foreach() loop, a read-only copy of the iteration variable is used and you cannot modify it. For example:
int pins = {9, 3, 7, 2}
int newPin = 10;
foreach(int pin in pins)
{
|
by: Hatem Nassrat |
last post by:
on Wed Jun 13 10:17:24 CEST 2007, Diez B. Roggisch deets at nospam.web.de wrote:
Well I have looked into this and it seems that using the list
comprehension is faster, which is reasonable since generators require
iteration and stop iteration and what not.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |