|
Certainly you'd want to close the login screen when you're finished with it. There are a few ways to do this. Also, you don't want to do a main.Show() in the login screen - you lose reuse and abstraction if you do that by tightly coupling the login and main screen.
To open the main screen after the login either call ShowDialog() on the login form from the main form's on load event or you can change your main() function to look like this:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LoginForm());
Application.Run(new MainForm());
}
Regards,
Rob Philpott.
|
|
|
|
|
Ampersand "&" is used as a special character in Windows Forms controls: it will cause the next character to be underlined. You can solve your problem by replacing each ampersand with a double ampersand.
Try something like:
lblCourse.Text += " " + acc.Course.ToString().Replace("&", "&&");
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
I'm trying to connect to Sybase Server (Adaptive Server Anywhere 6.0) from my C# application but failed to establish a connection.... it seems the C# use a default MSSQL driver. Below is the error:
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
below is the code:
//string bartsConnect = "Driver={Adaptive Server Anywhere 6.0};SRVR=MyServer;DB=MyDatabase;UID=myUserId;PWD=myPassword";
string myConnection = "server=ServerName;Database=myDatabase;uid=myUserId;pwd=myPassword";
SqlConnection myConnection = new SqlConnection(myConnection);
myConnection.Open();
hope to hear some answers soon,,,, thank you.
xxx
|
|
|
|
|
You are using an SqlConnection , which is specifically for SQL Server.
Try to use an OleDbConnection and you should be all right.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
yes, thank you but my problem is the connection string that i can be use to connect to Sybase(Adaptive Server Anywhere 6.0)... most of the examples in the net use access database..... can u give me the right connection string for the above server?...
xxx
|
|
|
|
|
Sorry I have no experience with Sybase, so I cannot help you with connection strings.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
|
I am trying to make a button to represent a volume control knob such as on a CD player in c#
The following error has croped up and i cant find any "Useful" information on what could be wrong.
Does anyone know how to resolve this Exception:
"WindowsFormsControlLibrary1.dll' doesn't contain any UserControl types."
Why would the namespace not contain a user control or could i have not linked the dll properly?
Thanx
|
|
|
|
|
I guess you get this error when you try to run your solution (F5) inside Visual Studio.
You cannot directly run a dll, you should set up an executable project in your solution and make it the "Startup Project" for the solution.
For example, create a new Windows Form executable and link your dll in it, in order to test your custom button.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
I've never seen such an exception before so have been looking around. Some people who've had this problem were trying to start the wrong project in the solution. Could this be it?
Don't understand that though, as if you try to start a .dll Visual Studio tells you not to be so stupid, and not with those words.
Regards,
Rob Philpott.
|
|
|
|
|
Thanx for the help.
I was thinking along those lines just before you posted.
I made a new project and linked to the user control i had creted to it, my button didnt do what it was meant to (due to my coding abitlity) although it did compile.
I think it may be because i had a form in the user command project to show its asthetics, and tried to run it on that which did not work.
may need to start a new thread on the functionality now thought.
Solved thanx for helping.
|
|
|
|
|
Hi !
I am looking for a tool to automatically encapsulate C++ library into C#.
I found some tutorials which tell me to first encapsulate classes in C++/CLI and then I could invoke my managed c++ classes into my C# project. But that's a lot of dummy work! I think automatics tools exist but I can't find them
Any suggestions ?
Thanks.
|
|
|
|
|
You can use Tlbimp[^] to automatically create a CLR assembly with the appropriate metadata for a COM type.
Simon
|
|
|
|
|
I found this tool, but it works only if your library is COM. That's not my case.
Do you know how to create automatically COM interfaces for my C++ library? So I can use tlbimp !
Create COM interfaces with my little hands is as uncomfortable as creating C++/CLI wrappers, I have more than 300 classes !
|
|
|
|
|
|
sbotz wrote: Do you know how to create automatically COM interfaces for my C++ library?
You can't. The library has to be specifically written to be exposed through COM.
There is no tool to automatically import a C library into a C# app. You have to write the extern references, defining the functions your importing and their parameters and passing methods, yourself. You'll need the documentation on that library because there is no way to determine what the expected parameters and their types are.
|
|
|
|
|
i have posted almost the same question earlier, but this one is more straitforward:
i want to handle events that raise by thread1 and process them with thread2, that's all!
or
i want to command thread2 to do sth from thread1
|
|
|
|
|
I had a look at your original post, and I think it will make it easier for you if you change your design a bit.
If I uderstand correctly, you want to show your main form, and then show a splash screen right on top of it with a progress bar showing the advancement of some intialization work carried out by a background thread.
Try this way:
- Use the standard Main() for a Windows Form application, which will just run the app showing the main form (Form1 ).
- In the Shown() event handler for Form1 , show the splash screen (Form2 ), create your thread, link its events to functions in Form2 and start the thread.
- When you get an event from the thread, use Invoke() to update the progress bar. As others told you, this is the best way to do that.
- If you feel unsure about Invoke() , set up a thread-safe (using lock ) property in Form2 and update it from the events handlers, then have a timer check it and update your progress bar. This is not good design, but it will work.
I hope I got your problem correctly, and hope this can help you.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
This would be a producer-consumer problem[^] it's really common so I'm sure there are lots of articles about it on CP.
Often implemented with a non-binary semaphore and a queue (or 2 semaphores and a circular buffer)
|
|
|
|
|
If thread2 is a UI thread, all you need to do is call Invoke/BeginInvoke on one of the controls created on that thread. Otherwise, the typical way is to share a queue between the two threads, and have the second thread watch the queue and process commands as they come in.
|
|
|
|
|
hi
my project is like this..
basing on the inputs given by user, i should generate a Drawing in Autocad
my problem is ...
client has so many Autocad versions
example: Autocad 2004,2005 ,2006,2007,2008,2009
and his requirement is like this ..
if the Current active Document belongs to Autocad 2006 then the drawing should be generated in that version apllication
what the client is saying is ..
suppose he opens Autocad 2006 application and runs the project then the drawing should be generated in Autocad 2006 application only
please help me
thanks in advance
vijay kumar d
|
|
|
|
|
Hi, i am using mysql connector for my C# project.
I want to retrieve all the values from the database where username = "testing"
Database.cs
public MySqlDataReader getAccountDetails(String username)<br />
{<br />
Connect();<br />
command = conn.CreateCommand();<br />
command.CommandText = "Select * from accounts where admin_num ='" + username + "'";<br />
reader = command.ExecuteReader();<br />
Close();<br />
return reader;<br />
}
frmMain.cs
private void frmMain_Load(object sender, EventArgs e)<br />
{<br />
toolStripDateLabel.Text = DateTime.Now.ToString();<br />
db.Connect();<br />
MySqlDataReader reader = db.getAccountDetails(username.ToString());<br />
<br />
while (reader.Read())<br />
{<br />
string thisrow = "";<br />
for (int i = 0; i < reader.FieldCount; i++)<br />
thisrow += reader.GetValue(i).ToString() + ",";<br />
listBox1.Items.Add(thisrow);<br />
}<br />
db.Close();<br />
}<br />
it gives me an error "Invalid attempt to Read when reader is closed."
|
|
|
|
|
|
benjamin yap wrote: public MySqlDataReader getAccountDetails(String username)
{
Connect();
command = conn.CreateCommand();
command.CommandText = "Select * from accounts where admin_num ='" + username + "'";
reader = command.ExecuteReader();
Close();
return reader;
}
You close the database connection after running ExecuteReader() , that's your problem. When you close the connection, the associated reader is closed too.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|