Click here to Skip to main content
15,898,831 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to confirm Security risk alert in C# web browser Pin
Richard Deeming25-Feb-14 7:16
mveRichard Deeming25-Feb-14 7:16 
GeneralRe: how to confirm Security risk alert in C# web browser Pin
Bernhard Hiller25-Feb-14 21:39
Bernhard Hiller25-Feb-14 21:39 
QuestionCreating DTO using TDD approach Pin
ramsai197325-Feb-14 1:22
ramsai197325-Feb-14 1:22 
Questionhow to restore a sql database programmatically in c#? Pin
rincy sivan24-Feb-14 23:35
rincy sivan24-Feb-14 23:35 
AnswerRe: how to restore a sql database programmatically in c#? Pin
Nicholas Marty24-Feb-14 23:54
professionalNicholas Marty24-Feb-14 23:54 
AnswerRe: how to restore a sql database programmatically in c#? Pin
OriginalGriff24-Feb-14 23:57
mveOriginalGriff24-Feb-14 23:57 
AnswerRe: how to restore a sql database programmatically in c#? Pin
Raj Mouli26-Feb-14 19:44
Raj Mouli26-Feb-14 19:44 
AnswerRe: how to restore a sql database programmatically in c#? Pin
Raj Mouli26-Feb-14 19:45
Raj Mouli26-Feb-14 19:45 
QuestionSerialComm Port to send and receive sms Pin
yomag4chi24-Feb-14 21:51
yomag4chi24-Feb-14 21:51 
AnswerRe: SerialComm Port to send and receive sms Pin
Richard MacCutchan24-Feb-14 22:04
mveRichard MacCutchan24-Feb-14 22:04 
AnswerRe: SerialComm Port to send and receive sms Pin
OriginalGriff24-Feb-14 22:29
mveOriginalGriff24-Feb-14 22:29 
Questionhow to prevent form open twice Pin
Aman Susanto24-Feb-14 2:50
Aman Susanto24-Feb-14 2:50 
AnswerRe: how to prevent form open twice Pin
johannesnestler24-Feb-14 3:15
johannesnestler24-Feb-14 3:15 
GeneralRe: how to prevent form open twice Pin
Eddy Vluggen24-Feb-14 6:57
professionalEddy Vluggen24-Feb-14 6:57 
GeneralRe: how to prevent form open twice Pin
johannesnestler24-Feb-14 8:12
johannesnestler24-Feb-14 8:12 
AnswerRe: how to prevent form open twice Pin
BillWoodruff24-Feb-14 6:41
professionalBillWoodruff24-Feb-14 6:41 
You can do this without using Reflection; you can use Activator.CreateInstance:
C#
Form newForm = (Form) Activator.CreateInstance(Type.GetType(YourNameSpace + "." + YourNewFormName));
Keep in mind that when you create a new Form of some specific Type, like a new "Form4," and cast it to the generic Type 'Form: the new Form has an empty string for its 'Name property. So, you can't test if the new Form exists in the Application.OpenForms collection by using its Name. To fix that: give the new Form a Name when you create it:
C#
Form newForm = (Form) Activator.CreateInstance(Type.GetType(YourNameSpace + "." + YourNewFormName));
newForm.Owner = this;
newForm.Name = YourNewFormName;
newForm.Show();
I'd like to suggest you define your own List<string> of currently opened secondary Form names; it will simplify testing for an instance being already opened. You can also pre-define a string with your NameSpace plus "." to make creating a new Form simpler.
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet


modified 24-Feb-14 12:51pm.

AnswerRe: how to prevent form open twice Pin
Richard Deeming24-Feb-14 9:00
mveRichard Deeming24-Feb-14 9:00 
GeneralRe: how to prevent form open twice Pin
BillWoodruff24-Feb-14 13:21
professionalBillWoodruff24-Feb-14 13:21 
SuggestionRe: how to prevent form open twice Pin
azhar9925-Feb-14 20:50
azhar9925-Feb-14 20:50 
QuestionA first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in Microsoft.Phone.Data.Internal.ni.dll Pin
Gene Lim23-Feb-14 22:40
Gene Lim23-Feb-14 22:40 
AnswerRe: A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in Microsoft.Phone.Data.Internal.ni.dll Pin
Naveen Kumar Krishnan24-Feb-14 1:18
Naveen Kumar Krishnan24-Feb-14 1:18 
GeneralRe: A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in Microsoft.Phone.Data.Internal.ni.dll Pin
Gene Lim24-Feb-14 2:53
Gene Lim24-Feb-14 2:53 
QuestionSQL SELECT Current User c# Pin
mcgurdan22-Feb-14 9:49
mcgurdan22-Feb-14 9:49 
AnswerRe: SQL SELECT Current User c# Pin
Ravi Bhavnani22-Feb-14 11:13
professionalRavi Bhavnani22-Feb-14 11:13 
QuestionHow do I inherit ComboBox to implement my function Pin
Member 1041329221-Feb-14 21:50
professionalMember 1041329221-Feb-14 21:50 

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.