Click here to Skip to main content
15,914,371 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: how to store the image Pin
Anup_Debnath22-Dec-08 18:12
Anup_Debnath22-Dec-08 18:12 
GeneralRe: how to store the image Pin
Giorgi Dalakishvili22-Dec-08 18:43
mentorGiorgi Dalakishvili22-Dec-08 18:43 
QuestionClose web browser control Pin
raja baireddy21-Dec-08 18:52
raja baireddy21-Dec-08 18:52 
GeneralRe: Close web browser control Pin
Luc Pattyn22-Dec-08 2:27
sitebuilderLuc Pattyn22-Dec-08 2:27 
GeneralRe: Close web browser control Pin
raja baireddy23-Dec-08 1:34
raja baireddy23-Dec-08 1:34 
GeneralRe: Close web browser control Pin
Luc Pattyn23-Dec-08 1:51
sitebuilderLuc Pattyn23-Dec-08 1:51 
GeneralRe: Close web browser control Pin
raja baireddy23-Dec-08 2:44
raja baireddy23-Dec-08 2:44 
QuestionFont (.ttf) file gets locked after rendering - can't delete! Pin
Senator Scratch21-Dec-08 9:11
Senator Scratch21-Dec-08 9:11 
I have an application which renders fonts in textboxes so the user can see what they look like. I then need to be able to delete that file. But when I try, I get an error because the file is locked.

I have figured out that if the textbox is never rendered to the screen, no lock occurs (so it's not the pfc or ff stuff, nor is the file read-only) (also, once I stop debugging, I can delete the file manually).

The Kicker: Only certain Fonts do this. bajoran.ttf gets this error, but TKDS9HOL.TTF does not.

Here is my code. Anybody have any ideas?
------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO; //manual add
using System.Drawing.Text; //manual add

namespace FontFileTest
{
public partial class Form1 : Form
{
string strFile = "bajoran.ttf";
//string strFile = "TKDS9HOL.TTF";

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile(strFile);
FontFamily ff = pfc.Families[0];
txt.Text = "Sample";
txt.Font = new Font(ff.Name, 12, FontStyle.Regular);
txt.Visible = true; //remove this line, will not lock
ff.Dispose(); //irrelevant
pfc.Dispose(); //irrelevant
}

private void btnDelete_Click(object sender, EventArgs e)
{
//extra stuff to try--irrelevant
txt.Font = new Font("System", 12, FontStyle.Regular);
txt.Dispose();
Application.DoEvents();
this.Refresh();

try
{
File.Delete(strFile);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
return;
}
lblStatus.Text = "Deleted";
}
}
}
AnswerRe: Font (.ttf) file gets locked after rendering - can't delete! Pin
EliottA21-Dec-08 15:56
EliottA21-Dec-08 15:56 
GeneralRe: Font (.ttf) file gets locked after rendering - can't delete! Pin
Senator Scratch22-Dec-08 12:31
Senator Scratch22-Dec-08 12:31 
GeneralRe: Font (.ttf) file gets locked after rendering - can't delete! Pin
EliottA22-Dec-08 13:07
EliottA22-Dec-08 13:07 
AnswerRe: Font (.ttf) file gets locked after rendering - can't delete! Pin
Eddy Vluggen16-Jan-09 4:56
professionalEddy Vluggen16-Jan-09 4:56 
AnswerRe: Font (.ttf) file gets locked after rendering - can't delete! Pin
Senator Scratch17-Jan-09 9:41
Senator Scratch17-Jan-09 9:41 
Questionneed to disable special key Pin
Anup_Debnath19-Dec-08 19:32
Anup_Debnath19-Dec-08 19:32 
AnswerRe: need to disable special key Pin
Giorgi Dalakishvili19-Dec-08 23:08
mentorGiorgi Dalakishvili19-Dec-08 23:08 
GeneralRe: need to disable special key Pin
EliottA21-Dec-08 15:55
EliottA21-Dec-08 15:55 
QuestionHow to close all process in one click Pin
Anup_Debnath19-Dec-08 18:41
Anup_Debnath19-Dec-08 18:41 
AnswerRe: How to close all process in one click Pin
Giorgi Dalakishvili19-Dec-08 23:09
mentorGiorgi Dalakishvili19-Dec-08 23:09 
QuestionShowDialog with MDIChildren Pin
Farid Deaibess19-Dec-08 2:26
Farid Deaibess19-Dec-08 2:26 
AnswerRe: ShowDialog with MDIChildren Pin
Dave Kreskowiak19-Dec-08 5:15
mveDave Kreskowiak19-Dec-08 5:15 
Question[Message Deleted] Pin
Anup_Debnath19-Dec-08 2:15
Anup_Debnath19-Dec-08 2:15 
AnswerRe: How to Disable/Enable Takmanger In .net Pin
Dave Kreskowiak19-Dec-08 5:12
mveDave Kreskowiak19-Dec-08 5:12 
Questioninstall databse automatically............. Pin
grks18-Dec-08 22:24
grks18-Dec-08 22:24 
QuestionDataGridView Custom Object RowState Functionality Pin
Jim Huskey18-Dec-08 3:21
Jim Huskey18-Dec-08 3:21 
AnswerRe: DataGridView Custom Object RowState Functionality Pin
Mycroft Holmes21-Dec-08 13:49
professionalMycroft Holmes21-Dec-08 13:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.