المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem with the ListView control



C# Programming
04-07-2009, 05:39 AM
Hello everybody,

My application uses a ListView control to display a list of files. Everything works fine except that when I set the View property of the ListView to View.List, the list appears but, here's (http://www.hotlinkfiles.com/files/2432437_yuetp/lv1.JPG)[^ (http://www.hotlinkfiles.com/files/2432437_yuetp/lv1.JPG)] a screenshot of how it looks. I can't understand, why the filenames are condensed and appended with a "...". I've searched google and msdn, but couldn't found a solution for the problem. The Large Icon (http://www.hotlinkfiles.com/files/2432436_upqsj/lv2.JPG)[^ (http://www.hotlinkfiles.com/files/2432436_upqsj/lv2.JPG)] and Details Views (http://www.hotlinkfiles.com/files/2432438_3mohj/lv3.JPG)[^ (http://www.hotlinkfiles.com/files/2432438_3mohj/lv3.JPG)] are working perfectly. Just the list view is misbehaving.

My second problem is regarding a BackgroundWorker. I have a BGWKR that I'm using to perform a database transaction. Now the problem is that the user may close the form while the transaction is in progress. To handle this, I added code to the form's closing event handler, to inform the user that a transaction is active and ask him/her, whether to cancel it. If the user affirms, then a call to BGWKR.CancelAsync() is made. Here's the form_closing event.


private void WndSearchResults_FormClosing(object sender, FormClosingEventArgs e)
{
if (bgDatabaseSearcher.IsBusy)
{
if (MessageBox.Show(Resources.msgSearchActive_WindowClosing, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
e.Cancel = true;
return;
}
else
{
bgDatabaseSearcher.CancelAsync();
while (bgDatabaseSearcher.IsBusy)
Thread.Sleep(500);
}
}
}


Here's the BGWKR's Do_Work event
private void bgDatabaseSearcher_DoWork(object sender, DoWorkEventArgs e)
{
VFS virtualFS = new VFS();

foreach (ListEntry entry in imagesToSearch)
{
lViewSResultsBrowser.Groups.Add(entry.imageID.ToString(), entry.imageName);

try
{
virtualFS.OpenConnection(Path.Combine(AppSettingsManager.ImagesDirectory, entry.imageDbPath));
foreach (VFSSearchTerm searchTerm in termsToSearch)
{
virtualFS.SearchVFS(searchTerm, searchOptions, SearchResultProcessor, entry.imageID);
if (bgDatabaseSearcher.CancellationPending) /* The control doesn't reach this point if a call to CancelAsync() has been made from the form closing event. */
{
virtualFS.CloseConnection(true);
return;
}
}
}
finally
{
virtualFS.CloseConnection(true);
}
}
}


However, the DoWork methods cancels gracefully if CancelAsync() is called from a button's click event handler.

Please help.
Thanks

Excuse me for buttin' in, but I'm interrupt driven.