|
madhusri wrote: since we assigned i=null then the singleton must be destroyed and new instance should be created when j = single.CreateInstance(); executed right?
Nope, wrong!
See this code from CreateInstance:
if (s == null)
s = new single();
return s; What happens here is the one and only ever instance never to be repeated is created if it does not exist and stored in the static field called s. s is always returned. Nothing else ever assigns to s therefore the singleton pattern is maintained becuase you have ensured that there will only ever be one and only one ever instance of the object. This is the goal of the singleton, the behaviour you expect is at odds with the pattern you have chosen.
|
|
|
|
|
I want to set the font style to Bold when the user clicks Control + B key combination,
How do i do that?
Thanks & Regards,
Pramod
|
|
|
|
|
private void richTextBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.B && e.Modifiers == Keys.Control)
{
this.richTextBox1.SelectionFont = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
}
}
|
|
|
|
|
|
You could also maintain the font and do it like this:
if (e.KeyCode == Keys.B && e.Control)
{
richTextBox1.SelectionFont = new Font(
richTextBox1.SelectionFont,
richTextBox1.SelectionFont.Style ^ FontStyle.Bold
);
e.Handled = true;
}
Michael Francik
Empireland, Inc.
|
|
|
|
|
Everything is fine
but when i press Ctrl + I the cursor moves one tab ahead,
Why does this happen?
is Ctrl + I any pre-defined short cut for richtextbox.
i am working in VS 2005.
Thanks,
Pramod
|
|
|
|
|
Thanks for that can also tell me how can i insert a link to a Folder in a richtext box.
Pramod
|
|
|
|
|
See this:
http://msdn2.microsoft.com/en-us/library/f591a55w.aspx
|
|
|
|
|
i tried but when i set a link as http://microsoft.com the text display should be only microsoft.com , but the text displayed is http://microsoft.com
please suggest Any other way to solve this.
Thanks,
Pramod
|
|
|
|
|
For example, if you want to open Directory c:\ then use
file:\\c:\
or if you want to open d:\temp then use
file:\\d:\temp
|
|
|
|
|
Hi,
How do i control access to a directory or file in a network programatically .Im using .Net Framework 1.1
(I have to restrict access to network for a particular user programatically)
Thanks in advance,
Luck is Opportunity with hardwork
|
|
|
|
|
Anything you do programmatically is in the context of the user that is running your program. If you want to kill access for a user, you cannot change a directory access while 'being' that user.
The only way is with network security setting the access rights on the folder. That's why we have network administrators in the world.
|
|
|
|
|
Thanks for your comments..
But is it possible to watch a directory for any changes,like we have FileSystemWatcher for files.
(or)
Is it possible to raise an Event if a shared directory is being accessed in windows.
I am using .Net Framework 1.1
Thanks in advance..
Luck is Opportunity with hardwork
|
|
|
|
|
Hi,
I need to develop a .NET application in C# that will run in a client machine.
This application should connect to a sharepoint server running in another machine, authenticate using username and password, and copy specified files from the sharepoint portal server.
I tried to use Microsoft.Sharepoint dll in the client side code, but the following error was occurring "But when I run the Application it says that the COM component is not registered or unavailable" . i feel the dll should be used only in the sharepoint server machine only.
Could someone help me in how to go about doing this.. if possible, some code snippetts will be of great help.
Thanks
Nishanth
|
|
|
|
|
Hi
I want to print a batch of invoices using crystal report. Now I am doing this using selection formula so it will send report by report to the printer.
There is an option call Group selection formula but I don’t know how to use this, is it a another way to get it done???
Shone
|
|
|
|
|
We use follwing code to create .avi file
IBaseFilter mux;
IFileSinkFilter sink;
int hr = capGraph.SetOutputFileName(MediaSubType.Avi, fileName, out mux, out sink);
DsError.ThrowExceptionForHR(hr);
hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, theDeviceCapture, theCompressor, mux);
DsError.ThrowExceptionForHR(hr);
WE want to change fileName ,but, when we make this, the second part of code give following error
System.Runtime.InteropServices.COMException was unhandled
Message="One or more arguments are invalid"
Source="DirectShowLib"
ErrorCode=-2147024809
How can create .avi files which have different names from capture card in C#
Murat Coşkun
Design Engineer
VESTEK Elektronik Arastima Gelistirme A.S.
E-Mail : murat.coskun@vestel.com.tr
|
|
|
|
|
Hello all,
i want to show millseconds along with longtime.
how to do this
regards
GV Ramana
|
|
|
|
|
Is this what you want ?
DateTime now = DateTime.Now;
Console.WriteLine(now.Millisecond);
Console.WriteLine(now.Ticks);
|
|
|
|
|
I haven't tried this, but I think that you can combine a standard format with a custom format in a format string: "D.fff".
---
b { font-weight: normal; }
|
|
|
|
|
hi all,
how can i process date info and insert into database (into a date/time field) without any difficulty ?
i mean there are some differences between date format in different countries. (for example: english > MM/dd/yyyy or turkish > dd/MM/yyy)
how can i first check the language info used by the computer then process date according to that with c# ?
help please ...
|
|
|
|
|
You could use a CultureInfo instance for formatting as shown below:
DateTime dt = DateTime.Parse("08/01/2006");
// Use the machines current culture.
Console.WriteLine("Current Culture: {0}.", dt.ToString(CultureInfo.CurrentCulture));
// If you want to use another culture without switching your current culture you could try.
Console.WriteLine("English (US) Formatted Date: {0}.", dt.ToString(new CultureInfo("en-US")));
Console.WriteLine("English (GB) Formatted Date: {0}.", dt.ToString(new CultureInfo("en-GB")));
// Output
English (US) Formatted Date: 8/1/2006 12:00:00 AM.
English (GB) Formatted Date: 01/08/2006 00:00:00.
|
|
|
|
|
Message Closed
modified 27-Apr-15 11:20am.
|
|
|
|
|
This should do the trick:
Console.WriteLine("English (US) Formatted Date: {0}.", dt.ToString("d", new CultureInfo("en-US")));
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hello!
I just wonder how can this small code fragment work when I have Main method as
private. How can the runtime part(CLR) access main method when it is private.
public class myApp
{
private static void Main()
{
System.Console.WriteLine("Main is now private ");
}
}
//Tony
|
|
|
|
|
You can also use Reflection to call private method in a class.
|
|
|
|