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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Oct 14, 2008, 3:35 PM
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 :-)
sairamPosted Oct 14, 2008, 6:41 PM
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