|
This is a small problem to sending text without attachment file, need your help me??
|
|
|
|
|
It'd probably be easier to tackle both problems separately; mailing a text and encrypting a text.
So, what's the problem with above code? Does it throw an exception? Does it encrypt?
If you're having trouble decrypting the text on another machine, then take in consideration that you're generating a new key
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, I will send encryption file using mail but code above only file attachment which sending. how to i adding the code to sending encrypt file without attachment. thanks
|
|
|
|
|
KaKoten wrote: how to i adding the code to sending encrypt file without attachment You're now encoding the text from "TextBox6", writing the result to "TextBox5". The contents of TextBox5 are written to the body, so I would expect it to encrypt the body.
If that works, then you'd only have to stop adding the attachment, and it would behave as requested.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
which only sending the attachment in this??
obj_Attachment = new System.Net.Mail.Attachment(textBox7.Text);
whereas which ignored by app is this and only side
Obj_MailMsg.Body = textBox5.Text;
how i add the code to sending only textbox5 which in encryption without attachment. thanks
|
|
|
|
|
KaKoten wrote: which only sending the attachment in this?? That line turns the content of the textbox into an attachment. Remove it if you're going to send mail without attachments.
KaKoten wrote: how i add the code to sending only textbox5 which in encryption without
attachment You don't need to add code to do that, only remove code. I assume that it IS encrypting the body correctly, and that you'd only want to remove the attachment.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
but I need the both without remove the both??
|
|
|
|
|
No, just the first
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks, but there a good another idea
|
|
|
|
|
Question:
How do you read pairs of lines from reader to make entries in lookup, until the end of the file is reached, The two lines in a pair become the key and value for an entry in lookup.
Ex. if the remaining file lines are the four at the right, then two entries would be made in lookup, one with key "up" having value "down", and one with key "in" having value "out".
I'd like to use this function:
public static void FileToDict(StreamReader reader,
Dictionary<string, string=""> lookup)
{
}
This is what i've come up with so far.. I am totally lost. Help with anything please!
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
List<string>< list = new List<string, string="">()
{
"Up","down",
"In","out"
};
Dictionary<string, string=""> dictionary = values.ToDictionary(x=>, x =>true);
Foreach (KeyValuePair<string, string=""> pair in dictionary)
{
Console.WriteLine(pair);
}
}
}
}
|
|
|
|
|
First off, you should think more modularly; don't have the method accept the StreamReader, have it accept an IEnumerable of strings.
Secondly, don't have it accept the Dictionary and return void; have it return the Dictionary.
So look at System.IO.File.ReadAllLines[^] as a source of an IEnumerable of strings from a file.
Then you should know how to use String.Split or even a RegularExpression to get the values from the strings.
Then stick them into the Dictionary.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
awesome thank you for your help!
|
|
|
|
|
Hi,
I have created a user control with txtFirstName and txtLastName fields on it.
On my frmPassengers, I am populating the user control more than one time based on the number user decided to add like this:
private void frmPassengerDetails_Load(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
BaseLayoutItem prevItem = layoutControlPassenger.Root;
for (int i = 1; i < total_adults; i++)
{
ctlPassengers uc = new ctlPassengers() { PassText = "Passenger " + i };
LayoutControlItem item = layoutControlPassenger.AddItem("", uc, prevItem, DevExpress.XtraLayout.Utils.InsertType.Bottom);
item.TextVisible = false;
item.SizeConstraintsType = SizeConstraintsType.Custom;
item.MinSize = new Size(830, 75);
item.MaxSize = new Size(830, 75);
prevItem = item;
}
}
so if user choosed 5 for the total_adult value then the user control will be populated five times.
Now I want to know how can I read the value of every txtFirstName and txtLastName on the form (the five of it for example)..
Technology News @ www.JassimRahma.com
|
|
|
|
|
Add a list to your form (e.g. List<ctlpassengers>) to which you add your user controls as you create them. This avoids having to traverse the visual tree later to get at them.
Once you're ready to read back the name values, iterate over the controls in the previously created list.
|
|
|
|
|
sorry I didn't get you...
Technology News @ www.JassimRahma.com
|
|
|
|
|
txtFirstName and txtLastName are "text boxes" in your "user control"; right?
To access the text box contents (.Text) you need a reference to the users controls and the text boxes; no?
Aren't you creating these "user controls" on the fly and adding them to your (devExpress) form?
If not, what was the purpose of the code you posted?
|
|
|
|
|
You are right in all but in this case I am creating multiple controls from the same user control. The user control has just one txtFirstName but when users sets total_adults=5 in Form1 then five txtFirstName controls will be created on the Form2
Thats why I am asking how can I change the property class to return the value and from Form2 I need when clicking Save to save read the value of all fives txtFirstName controls.
Thanks
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
Add a list to your form:
list<uc> mylist = new list<uc>.
As you create and add uc's to the form, add them to the list also:
mylist.add(myuc)
When you click "save", iterate the list to access controls and their contents:
foreach ( uc myuc in mylist){
.... myuc.txtFirstName.Text ...
etc.
}
One set of controls; multiple "references" to those controls: form; list.
|
|
|
|
|
I think you have to create a method form doing this.
If you have limit for total adults its easy else you have go for Max value.
If you say 10 is the maximum adult capacity.
List<string> lstFirstName=new List<string>();
List<string> lstSecondName=new List<string>();
void RetrieveValues()
{
if(adultCount>0)
{
for(int i=1;i<=adultCount;i++)
{
string first=txtFirstName.Name+i.ToString();
string second=txtSecondName.Name+i.ToString();
lstFirstName.Add((TextBox)first.Text);
lstFirstName.Add((TextBox)second.Text);
}
}
}
This may work. If its not working please reply with the error you are facing.
|
|
|
|
|
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<myControls> lst;
private void button1_Click(object sender, EventArgs e)
{
int max = int.Parse(txtInput.Text);
lst = new List<myControls>();
for (int i = 0; i < max; i++)
{
new myControls();
lst.Add(new myControls());
}
}
private void button2_Click(object sender, EventArgs e)
{
foreach (var item in lst)
{
MessageBox.Show(item.Name);
}
}
}
class myControls
{
public string Name;
public TextBox t;
public Label l;
}
//by default control's modifiers property is set to private. Make it public to access from other classes.
modified 3-Sep-19 21:02pm.
|
|
|
|
|
Hi, I have made a program to compare the pages of 2 books using the overloading concept. But i m not sure that is correct or not. Please see my code and tell me whether my program is logically correct or not based on the concept..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace comp
{
class book1
{
public int page1;
}
class book2:book1
{
public int page2;
public book2(int p1 ,int p2)
{
page1 = p1;
page2 = p2;
}
public static bool operator <(book2 b1, book2 b2) // overloading
{
if (b1.page1 < b2.page2)
return (true);
else
return (false);
}
public static bool operator >(book2 b1, book2 b2)
{
if (b1.page1 > b2.page2)
return (true);
else
return (false);
}
}
class Program
{
static void Main(string[] args)
{
book2 b2 = new book2(5,10); // passing parameters
if (b1.page1 < b2.page2)
{
Console.WriteLine("book 1 has less pages than book 2");
}
else if (b1.page1 > b2.page2)
{
Console.WriteLine("book1 has more pages than book 2");
}
Console.ReadLine();
}
}
}
|
|
|
|
|
Whoa, there's quite a lot which is not right there.
By the look you have overloaded operators to compare books, but you are actually comparing pages!
Regards,
Rob Philpott.
|
|
|
|
|
Hey rob, i thought better to compare the no. of pages of the books .. But if i compile this it wont print the message.( I m new to this overloading concept). What do you suggest how it should be then ??
|
|
|
|
|
OK. Why do you have two book classes, one derived from the other?
In OOD, when you derive something it specializes the thing it derives from. In this case, it adds a second integer member called Page2. What's going on here?
If you can, avoid this as this is just a distraction from what you're trying to do - operator overloading.
Regards,
Rob Philpott.
|
|
|
|
|
As Rob has said, deriving from a base class specialises something - a book does not derive from a previous book except when it is an expanded version: the Directors Cut if you like.
Think about it: a "Book by Charlotte Bronte" derives from "Book", and so does a "Book by Terry Pratchett" - but that is pretty much the only thing they have in common: the elements which are common to all books (Pages, a cover, a title, an author) and so forth.
You wouldn't overload a method to get a number of pages from two different books, because the number of pages is a property of the individual instance on the book. But... you might overload it to get different information which is also instance specific:
public class Book
{
private int pages;
private List<int> chapters = new List<int>();
public int GetPages()
{
return pages;
}
public int GetPages(int chapter)
{
int lastPage = pages;
if (chapter >= chapters.Count || chapter < 0) return 0;
if (chapter != chapters.Count - 1) lastPage = chapters[chapter + 1];
return lastPage - chapters[chapter];
}
}
This has two overloaded GetPages methods.
If you don't supply any parameters it returns the number of pages in the book.
If you pass it an integer, it returns the pages in that chapter.
The type of the parameter determines which version of the method gets called, and thus what the method does.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|