|
MouseLocation is it a proprties? of which object?
|
|
|
|
|
Yes - you have to work relative to the Form Location property, but it's pretty simple:
private void frmMain_Load(object sender, EventArgs e)
{
Cursor.Position = new Point(Location.X + 10, Location.Y + 10);
}
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 – ∞)
|
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
{
Point mid = new Point(Width / 2, Height / 2);
Cursor.Position = new Point(this.Left + mid.X, this.Top + mid.Y);
}
Happy Coding...
modified 3-Sep-19 21:02pm.
|
|
|
|
|
I’m developing a Window’s forms application for collecting and graphing historical data and utilizing a monthcalendar control that allows the user to select a day or range of days for graphing (MaxSelectionCount = 7). Additionally, since the user should never be selecting future dates, I have set the maxdate property to today (DateTime.Now).
Utilizing this configuration the user is allowed select any individual valid date (including today) without a problem, AND the user is allowed select any group of “previous” dates without a problem. However, the control will NOT allow the user to select a range of dates that includes today. Any ideas on why this doesn’t work???
I can even set the MaxDate to tomorrow (DateTime.Now.AddDays(1)) with similar results; However, setting MaxDate to the day after tomorrow (DateTime.Now.AddDays(2)) DOES allow the user to select a range including today… But it also lets them select a range of dates that includes tomorrow, and the day after tomorrow can be selected as an individual date…
Kip
|
|
|
|
|
The MaxDate property works up to the exact DateTime that you set: but DateTime.Now includes the hours, minutes and seconds - so setting MaxDate to it pretty much excludes the final date from a range as it has already passed (I think - I haven;t looked at the .NET code). What you need to do is set it to the end of day that you want to include:
myMonthCalendar.MaxDate = DateTime.Now.AddDays(1).Date.AddSeconds(-1); Should do it.
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 – ∞)
|
|
|
|
|
Or just use DateTime.Today.
|
|
|
|
|
You could, but you'd have to make it:
myMonthCalendar.MaxDate = DateTime.Today.AddDays(1).AddSeconds(-1);
DateTime.Today is midnight last night, which gives the same problem on it's own.
But it's tidier with Today, I'll admit!
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 – ∞)
|
|
|
|
|
Thank you for the quick replies! I went with the “DateTime.Today.AddDays(1).AddSeconds(-1)” solution. Works great; thanks again!
|
|
|
|
|
You're welcome!
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 – ∞)
|
|
|
|
|
As we can't see your code, we have no way other than randomly guessing.
|
|
|
|
|
I don't randomly guess, I try it!
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 – ∞)
|
|
|
|
|
how to add coding to send Encryption text via smtp mail and this is the code. thanks
private void SendMail_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
{
MessageBox.Show("Require, must content the row !!!");
}
else
try
{
obj_SMTPClient = new SmtpClient("smtp.gmail.com");
Obj_MailMsg = new MailMessage();
obj_Attachment = new System.Net.Mail.Attachment(textBox7.Text);
Obj_MailMsg.From = new MailAddress(textBox1.Text);
Obj_MailMsg.To.Add(textBox3.Text);
Obj_MailMsg.Body = textBox5.Text;
Obj_MailMsg.Attachments.Add(obj_Attachment);
Obj_MailMsg.Subject = textBox4.Text;
SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
obj_SMTPClient.Credentials = new NetworkCredential();
obj_SMTPClient.Port = 587;
obj_SMTPClient.Credentials = new System.Net.NetworkCredential(textBox1.Text, textBox2.Text);
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
MessageBox.Show("Message Successfuly Sent!!!");
}
catch
{
MessageBox.Show("Failed to Send Message!!!");
}
}
private void EncryptionText_Click_1(object sender, EventArgs e)
{
cipherData = textBox6.Text;
plainbytes = Encoding.ASCII.GetBytes(cipherData);
desObj.GenerateKey();
desObj.GenerateIV();
desObj.Mode = CipherMode.CBC;
desObj.Padding = PaddingMode.PKCS7;
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms,
desObj.CreateEncryptor(),
CryptoStreamMode.Write);
cs.Write(plainbytes, 0, plainbytes.Length);
cs.Close();
cipherbytes = ms.ToArray();
ms.Close();
textBox5.Text = Encoding.ASCII.GetString(cipherbytes);
}
private void DecryptionText_Click_1(object sender, EventArgs e)
{
MemoryStream ms1 = new MemoryStream(cipherbytes);
CryptoStream cs1 = new CryptoStream(ms1,
desObj.CreateDecryptor(),
CryptoStreamMode.Read);
plainbytes = new Byte[cipherbytes.Length];
cs1.Read(plainbytes, 0, cipherbytes.Length);
cs1.Close();
ms1.Close();
textBox5.Text = Encoding.ASCII.GetString(plainbytes);
}
|
|
|
|
|
What's the problem?
That's just code without any explanation of the help you need.
Remember that we can't see your screen, access your HDD, or read your mind, so we only get what you tell us to work on.
Help us to help you!
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 – ∞)
|
|
|
|
|
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!
|
|
|
|