Hi,
I am inserting an image into the richtextbox from the folder in C drive. I want to restrict the images in such a way that only the images with less than 10KB is only inserted. How do i do that.
Please help
Hi,
I am inserting an image into the richtextbox from the folder in C drive. I want to restrict the images in such a way that only the images with less than 10KB is only inserted. How do i do that.
Please help
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 14, 2008, 11:35 AM EDT
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() ==DialogResult.OK)
{
String Filename = ofd.FileName.ToString();
Bitmap bmp = new Bitmap(Filename);
FileInfo finfo = new FileInfo(Filename);
long FileSize = finfo.Length;
MessageBox.Show(FileSize.ToString());
DataFormats.Format mydataformat = DataFormats.GetFormat(DataFormats.Bitmap);
Clipboard.SetDataObject(bmp);
if (richTextBox1.CanPaste(mydataformat))
{
if (FileSize < 10000)
richTextBox1.Paste(mydataformat);
else
MessageBox.Show("File Size Is bigger then Recommended ");
}
}
Hope it Will be Helpful to You
Happy Coding :-)
sairam73 reputationPosted Oct 14, 2008, 2:41 PM EDT
Thanks a Ton Kirtan. I got what i want.
One more Question.
My Windows form has Controls all over it. When i press a button at the bottom of the form, the focus is shifting upwards and that particular click event is not fired. Again if i press second time, then its working. Similarly if i click on a tree node on the form, the focus is shifting either up or down on the form. To be more precise, the tree node is getting selected, but the scrollbars are moving up and down and because of this the focus is not on the tree control. How shud i rectify it.
Thanks
Sairam