|
It works for me John (XP + VS2008) using the code you posted below. I just see the label (black border, white background and DarkRed text), the form is invisible.
John Simmons / outlaw programmer wrote: BTW, if I use ShowDialog() to display it, calling Form.Close() does not dismiss the form (but calling Close() does work when I use Form.Show()).
Where are you calling Close() from?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
It's a splash panel that is displayed during program initialization. I use a BackgroundWorker object to instantiate/close the form. Here's the code for the worker thread:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Threading;
namespace DownloadablePlayer
{
public partial class vPopcornPlayer : Form
{
BackgroundWorker m_splashWorker = new BackgroundWorker();
private void ShowSplashScreen()
{
m_splashWorker.WorkerReportsProgress = false;
m_splashWorker.WorkerSupportsCancellation = true;
m_splashWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(splashWorker_DoWork);
m_splashWorker.RunWorkerAsync();
}
private void HideSplashScreen()
{
if (m_splashWorker.IsBusy)
{
m_splashWorker.CancelAsync();
Thread.Sleep(500);
}
}
private void splashWorker_DoWork(object sender,DoWorkEventArgs e)
{
BackgroundWorker thisWorker = sender as BackgroundWorker;
SplashPanel2 splashPanel = new SplashPanel2();
splashPanel.Show();
while (!thisWorker.CancellationPending)
{
Thread.Sleep(500);
}
splashPanel.Close();
splashPanel.Dispose();
}
}
}
I call ShowSplashScreen() and HideSplashScreen() from a function elsewhere in the form. As you can see there's not a lot going on here. I fail to see why it won't work for me.
If I substitute splashPanel.Show() with splashPanel.ShowDialog() , the form is displayed, but then I can't seem to close it.
I hate .Net.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I hate .Net
LOL!
Will have a look at it in the morning (UK) and see if can figure out what's going on.
At first glance - it's not the way I handle splash forms myself (your way may be better!). I show the splash screen modally from the main form and have a backgroundworker on the splash screen which does the initialisation/loading etc. That way a simple ShowDialog() in the main form launches it and in the splash the RunWorkerCompleted calls a method which calls Close() and the main form is returned to automatically.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
My way is different, not necessarily better.
I'm going to take the code home tonight and run it under both VS2005 and VS2008, and see if I can duplicate the problem.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Just so you know, I figured out how to fix it (and posted a new message about it in this forum).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
i did a application that creates a new and empty database file(MDB file).
i want to create a new row in the new database.
i did this:
string connectionString = "provider=Microsoft.JET.OLEDB.4.0; " + "data source =" + Dir;
string commandString = "Select id,cell from Events";
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(commandString, connectionString);
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "Events");
DataTable datatable = ds.Tables[0];
DataRow newRow = datatable.NewRow();
newRow["id"] = "Gil";
newRow["Event"] = "Gil2";
datatable.Rows.Add(newRow);
dataAdapter.Update(ds, "Events");
ds.AcceptChanges();
it throws me a exception:
Update requires a valid InsertCommand when passed DataRow collection with new rows.
What is Wrong?..i am not understand
p.s
All of this is in try catch...
thank you!
|
|
|
|
|
you are not inserting new records. You are trying to update. But update what?
here this should help ^
Yusuf
|
|
|
|
|
You will need to define the InsertCommand property of the DataAdapter like so:
OleDbCommand insertCommand = connection.CreateCommand();
insertCommand.CommandText = "Insert Into Table(Col1, Col2, Col3) Values (?, ?, ?)";
dataAdapter.InsertCommand = insertCommand;
You may also want to check out the UpdateCommand and DeleteCommand properties which will allow your adapter to update and delete records which is what it seems you are also trying to do in your code snippet.
/F - .NET Developer
|
|
|
|
|
Hi,
I was wondering if anyone knows if a .Net Control exists(free/commercial) which can let me have a view like this:
http://www.bergsoft.net/res/screenshots/next-grid/slides-style.gif
The Column headers at the top are not required. Thanks for any information, I am a bit new at this!
regards,
Brendan.
|
|
|
|
|
You can do things like that fairly easily with WPF. You'd use a listview as a starting point, then add a template for the list view items.
Infragistics controls did have something that could do similar to that in winforms last time I used them (a few years ago now).
Simon
|
|
|
|
|
Hi,
Is it possible to save event logs using C# ?
Any idea ?
Thansk in advance !!
cheers,
Abhijit
|
|
|
|
|
You could use the EventLog object to read the event log entries and then save them to a database or file, like so:
EventLog eventLog = new EventLog("Application");
foreach (EventLogEntry entry in eventLog.Entries)
Console.WriteLine(entry.Message);
/F - .NET Developer
modified on Wednesday, July 30, 2008 10:23 AM
|
|
|
|
|
Use Microsoft Enterprise Library for Event Log, Flat file logging or Error Logging.
|
|
|
|
|
Thanks for your response. but i want to save it ".evt" file.
cheers,
Abhijit
|
|
|
|
|
I don't believe the .NET Framework has native support for this, but you can try the following:
[DllImport("advapi32.dll")]
static extern IntPtr OpenEventLog(string lpUNCServerName, string lpSourceName);
[DllImport("advapi32.dll")]
static extern bool BackupEventLog(IntPtr hEventLog, string backupFile);
BackupEventLog(OpenEventLog("localhost", "Application"), @"C:\TEMP\EVENTLOG.EVT");
/F - .NET Developer
|
|
|
|
|
Thanks for your reply. I am trying to do it using WMI
cheers,
Abhijit
|
|
|
|
|
how do i set printer options? i would like to set these options
print from tray 1
pagesize 11x17
landscape
this is the code i am using
System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
pd.PrinterSettings = printDialog1.PrinterSettings;
pd.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Simplex;
pd.DocumentName = "JP Council (Title Page)";
pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
i know it has to be something with the printersettings but just now sure how to do it
Thanks,
Chad Aiena
|
|
|
|
|
use
System.Drawing.Printing.PageSettings mySettings = new System.Drawing.Printing.PageSettings();
mySettings.PrinterSettings has everything you need.
Then apply mySettings to the System.Drawing.Printing.PrintDocument instance your using.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi i given in my form opacity=0 and set the form shown taskbar=false...,
To avoid form visible to my enduser...,
Now the probs is,
After my form load all the operations happend the form have to auto close?,
Its possible?,
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
Close();
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Perhaps you don't want a Windows Application at all?
Have you considered a console application?
Either way, the user should have some indication that something happened.
|
|
|
|
|
Hi guys i created one windows application its contained only one form...,
In that form load event i said some operations have to run...,
Its working cool...,
But i dont like show the window form to enduser...,
It mean no minimize of the form also, just the form load operations have to run thats all
So i tried to hide that using this.hide(); methode in my form load event...,
But its not getting hide...,
how to hide my form window?
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
You can put your code in the constuctor instead of load so it runs before the loading takes place unless you need to access the form itself (or child controls) as it's handle won't be created yet so the object(s) will be unavailable.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
If your only purpose is to execute a piece of code and not to show any window, you can simply delete the form and put your code in Main method.
Open Program.cs file and under main function comment out line which shows the form, and put your code. Such as –
---------------------------------
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
MessageBox.Show("Test");
}
}
---------------------
I hope this helps.
-Dave.
--------------------------------
www.componentone.com
--------------------------------
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
You could set the forms opacity to 0
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|