|
I may be wrong about this, but I think you have to add the handler to the Form object that contains the Panel, and test if the Panel has the focus.
|
|
|
|
|
Well, i tried to add the handler to the form object, but I can't.
Here's what i did:
public Form1()
{
...
this.KeyPress += new KeyPressEventHandler(this.keypressed);
...
}
void keypressed(Object o, KeyPressEventArgs e)
{
switch (e.KeyChar)//Here I made a breakpoint, but the debugger doesnt reach this point, when I
//press a button...
{
...
}
}
What's the problem?
MS Visual Studio.NET 2003
C#
|
|
|
|
|
Make sure the Form .KeyPreview property is set to true . There are some other good notes in the sdk documentation for Form .KeyPreview that you might want to check out.
I hope this helps--
--mike
|
|
|
|
|
Yeah, thanks.
That works.
MS Visual Studio.NET 2003
C#
|
|
|
|
|
I've started getting a very strange exception in my program.
An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module.
That happens sometimes when a window is created (not a specific window, has happened with messagebox and my own forms).
I am using .Net version 1.1. This is my first app with 1.1, so maybe there was some important detail I missed that has changed from 1.0 to 1.1?
I know threads and UI can cause a mess if done badly, but I am not doing any threading at all.
It seems that before the exception occurs, a new thread with no name is created.
VS cannot tell me anything about the thread: there is no call stack, the stack frame selector is unclickable... nothing.
|
|
|
|
|
Many threads are created that handle various things, like painting a control or for asynchronous operations. You never know.
Make sure you're compiling a debug build. There's other reasons you might not be able to use some of the debugging tools (threads are always funny when it comes to that), but just to eliminate the obvious I mentioned that.
If you think it has something to do with threading, check that your application's Main entry point is attributed with the STAThreadAttribute , which is the main UI thread. Usually, though, you get different errors if your application is started in anything other than an STA.
As far as changes 1.0 to 1.1, there really isn't much besides new methods and a few new classes, and a few methods and properties that are now obsolete - nothing conceptual is mentioned, though.
All I can think is to click on the Debug->Exceptions menu and break on all exceptions. Changes are that you'll end up looking at assembler code, but it should give you some stack frame if the debugging symbols are loaded. If you're not using a checked build of Windows, they are probably stripped. VC++ does install some program database (pdb files), but not for the core libraries. If you dig around though, you should at least be able to determine which library you're in. That could help solve the problem since most libraries are pretty specialized.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
OK, thanks for the help. I'll try and see what happens with all exceptions breaking into the debugger on throw.
|
|
|
|
|
(Not sure if i had to post this here, couldn't find a forums here more fitting, if it's supposed to go elsewhere please remove).
I just finished readying: "Teach yourself C# in 24 Hours, by James Foxall", it really was a nice book, but i feel there are parts it discussed that didn't "fill" my knowledge as much as i'd like. Could someone propose a book, a set of books, or a complete training course that it is best for, learning CSharp, understaning OOP as a concept, and taking you to the next level, an intermediate status to pro (well pro without a proffesional experience).
Thanks in advance
|
|
|
|
|
The next thing is to read all the .NET frameworks docs in MSDN from start to finish. That should keep you busy for a year or 2, but you will be a "pro" To reach the next level, you will have to study the EMCA-334/5 C#/.NET CLR specs to answer all your questions you have left After that stage, you can rename yourself to Heath Stewart or something :p
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thanks ofr pointing these things out for me, but the problem is, i don't trust myself yet to start searching on my own, performing quantum leaps. Even with having finished that book and all the examples/tests in it, i cannot write a simple program on my own, without having 100 backdraws and stuff. Meaning i cannot make code decisions yet, i just type like a blind and hope that this will work. That's why i asked for a book/s that will help me answer questions ( that maybe now i don't know i have, but will surely stumble upon later), and will serve as a quide to get me on knowledge-train, then i will surely have to dig on MSDN library (and CSharp Dev center). And i am also lacking OOP knowledge (only thing i know is what i've read in this book) 'cause C# is the first "real" language i started studying, no c++ background etc.
So if there's a book/s that would fit my needs as i mentioned above, please help me make the right choice
p.s. What is ECMA-334/5 C#/.NET CLR (common language runtime)?
|
|
|
|
|
leppie wrote:
After that stage, you can rename yourself to Heath Stewart or something :p
Good call.
- Nick Parker My Blog
|
|
|
|
|
|
Sorry for this question but I'm looking for a quick answer.
How does .NET load assemblies? - or better how does .NET find the assemblies to load?
For example: if I have myexe.exe which uses mydll.dll myseconddll.dll, etc. does the runtime scan the folder containing myexe.exe for all .dlls and loads them? What if I have 1000 .dlls in a single folder? Will the runtime load them all or just will scan them all?
My exact question is: I want to organize my program like that
main.exe
system/system.dll
system/gui.dll
plugins/someplugin.dll
plugins/moreplugins.dll
As you might guess what is in ./system/ will always be available and used by main.exe but what is in ./plugins/ could be different.
What methods do we have available to load .dlls? I'm currently reading Sam Haidar's article on late binding. Are there any other methods?
Could you please point me to information, where I can find an answer about this question.
I hope my question is clear enough.
|
|
|
|
|
.NET will first look if an Assembly with the same version number is in the GAC, then it falls back to the working executable's directory
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
It also looks in the private path, which can be configured in the application's .config file using the <probing> element (see SDK documentation for details).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Well, I did plugin loading by first just listing all the DLL files in the plugins directory and then calling Assembly.Load() (I think that's what it was called) for each of them and specifying the file as the parameter.
|
|
|
|
|
Hello
I am creating a database which will be used to display information and pictures for houses. I have done everything but be able to insert the pictures and retrieve them from the database.
This is the code l am using to make the connection with the database
//Example Connection
m_cnADONetConnection.ConnectionString = @"Provider=Microsoft.jet.OLEDB.4.0;data source=C:\Houses";
m_daDataAdapter = new OleDbDataAdapter("Select * From Houses",m_cnADONetConnection);
OleDbCommandBuilder m_cbCommandBuilder = new OleDbCommandBuilder(m_daAdapter);
m_daDataAdapeter.Fill(m_dtContacts);
//This is what i am using to retrieve from the database, not sure how to do this for a image control.
txtHouseID.text = Rows[rowPosition]["HouseID"].ToString();
To select the picture l want to add to the database, l am using a open dialog box, which works, but l can't add it to the database.
Many thanks in advance
Steve
|
|
|
|
|
First, learn to use OleDbParameter . This will greatly aide in your problems. Second, set the column in which you want to store the image to an OLEObject.
Then, you need to be able to read the image from a Stream as a byte[] array and assign it:
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO SomeTable (Name, Image) " +
"VALUES (@Name, @Image)";
cmd.Parameters.Add("@Name", OleDbType.VarWChar, 40).Value = "ImageName";
cmd.Parameters.Add("@Image", OleDbType.Binary).Value = image;
cmd.ExecuteNonQuery();
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for your help
I was starting to read up on the stream. Could you give me a example how to read the image from a stream as a byte data.
I am interested in using the parameters more, as it seems to be very useful. Is there any good tutorial on them.
Many thanks in advance
Steve
|
|
|
|
|
There's the .NET Framework SDK documentation - just type OleDbParameter in the index.
There's probably tutorials on this site and around the 'net, but they're not hard to use and the documentation offers plenty of information and examples.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
The OLE DB .NET Provider does not support named parameters for passing parameters to a SQL Statement or a stored procedure called by an OleDbCommand when CommandType is set to Text. In this case, the question mark (?) placeholder must be used. For example:
SELECT * FROM Customers WHERE CustomerID = ?
As a result, the order in which OleDbParameter objects are added to the OleDbParameterCollection must directly correspond to the position of the question mark placeholder for the parameter.
Thank You
Bo Hunter
|
|
|
|
|
|
Dear friends:
My team has the following task to complete.A solution that consists of 3 projects :
1-Win app that connected to a local DB server(SQL server) .
2-Web app that connected to a remotre server(SQL server).
3-Mobile app for that connected to tha same remote server of the web app.
The Details:
1-The win app deals with a DB(Local DB SQL server) for updating ,retriving,inserting and deleting.
2-The web & the mobile app deal with a DB(Remote DB SQL server) for tha same purpose.(updating ,retriving,inserting and deleting)
The Goal:
1-The Win app will connect one time per day to update the Remote SQL server with the new data from the Local SQL server.
2-The Web and mobile app connected to the Remote SQL server will update ,retrieve ,delete and insert records in it.
The Questions:
1-If I can use Asp.net web services ,How can I use it?
2-How can i make daily transaction to update the Remote SQL server with the new data at the Local SQL server??
3-How can i make daily transaction to update the Local SQL server with the new data at Remote SQL server ??
4-How can i manage the DB Transactions ?
5-how can i use the same methods(code) for dealing with the DB ,for the win app , the web app and the mobile app?
6-What is the best way to complete this solution?
Thanks for reading to this line.
I hope you can help me.
thanks again.
Best Regards
Ahmed Gaser
FCSIS
IS Dept.
|
|
|
|
|
Without going into details, .NET will provide you a complete solution, search the forum, similar questions like this has been asked when .NET was relatively new.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Hmmmm... This sounds suspiciously like a class project....
Some pointers - You'll have to do the grunt work yourself...
1. If you have the ability to use ASP.NET WebServices then you can use them to abstract your business logic what ever that happens to be in the context of this project.
2 & 3: Look for information on replication. Data publishers and data subscribers.
4. That depends on what you mean by "manage"... My own belief is to use stored procedures to manage all access to the database.
5. See 4
6. That is very vague. What are your priorities?
--Colin Mackay--
|
|
|
|