|
ok thanks i did it, but not work i compile without erors but nothink hepend when i push 'Enter' key. please look my code^
private void Form1_KeyPress(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
this.webBrowser1.Navigate(this.toolStripTextBox1.Text);
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Athlon 64 3500+, Gigabyte GA-K8NXP-9, 2x512 DDR400 Kingston, Inno3d 6200 PCIe, SS2 B2C2 v2.6, HDD := 450gb, Genius 56k int, NEC DVD-RW и мать его Суньмастер 550.
|
|
|
|
|
The if clause should work. Check in the debugger, if Form1_KeyPress is called, maybe you forgot to subscribe to the form.KeyPress event handler?
this.KeyPress += new KeyPressEventHandler(Form1_KeyPress);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi
I want to know how can i use the visual studio Query Builder I think it is in Microsift.VSDesigner assembly but I dont know how to use it.
Thank you for your help
|
|
|
|
|
Hi all,
I'm declaring a property...
<br />
public int Number ()<br />
{<br />
get <br />
{ <br />
return myInt; <br />
}<br />
set <br />
{ <br />
myInt = value;<br />
}<br />
}<br />
and I'm getting a build error. The complaint is coming from the get and set keywords, it is asking for a semi-colon (;) to be placed after each. I also believe that value should be a keyword (i.e. highlighted by the ide) which it is not.
Can anyone help because I thought this was pretty straightforward.
|
|
|
|
|
richiemac wrote: public int Number ()
Properties are declared without the brackets. The compiler thinks you're trying to declare a function.
Should be:
public int Number {
get {return MyInt;}
set {myInt = value;}
}
Share and enjoy.
Sean
|
|
|
|
|
public int Number
{
get
{
return myInt;
}
set
{
myInt = value;
}
}
try this.
|
|
|
|
|
Properties don't need brackets ( and ) in the method header
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks guys!
Knew it was something trivial.![D'Oh! | :doh:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_doh.gif)
|
|
|
|
|
I guess I'm missing something. I've designed a testbed app to help me learn C# (I come from a Delphi background) and I've got the menu set up. Plus I've added in the AboutBox form to my project. Now how do I open the AboutBox when I click on the Help|About... menu choice - what code do I stick in there to open AboutBox1? And then, once I've got the AboutBox open, what code do I put in at the Close button's Click event to make it go away?
In Delphi I'd just put in (on the main form's Help|About... Click procedure) the code:
AboutBox.Show;
Also in Delphi, I'd put in the AboutBox's Close button Click procedure the code:
Self.Close;
Can anyone give me a clue, maybe drop me a sample project at:
delphidb-AT-comcast-DOT-net
Derek Benner
|
|
|
|
|
In the Visual Studio dialog designer you can doubleclick on the menuitem, it will then generate the click code for you. You can then open the form like this:
AboutBox about = new AboutBox();<br />
about.ShowDialog();
Closing the form is easy as can be: Close();
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Okay. Tried that. Got it to work. Thanx!
One thing.
C# is *very* picky about them trailing Open and Close parens isn't it? '()'.
Derek
|
|
|
|
|
delphidab wrote: One thing.
C# is *very* picky about them trailing Open and Close parens isn't it? '()'.
Is this intended as sarcasm?
|
|
|
|
|
Not sarcasm, just an automatic response to an unexpected shock. Delphi doesn't require a procedure or function that doesn't need arguments to have the parens attached. You *can* but Delphi doesn't expect it and so most people don't waste their time typing them.
So either
Self.Close;
or
Self.Close();
are valid in Delphi.
Derek
|
|
|
|
|
delphidab wrote:
C# is *very* picky about them trailing Open and Close parens isn't it? '()'.
It's the same in C(++) and Java. All methods need parentheses regardless of whether they return something or not (void ).
But properties don't need parentheses.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Yeah, well... This is my first exposure to C#. It's been almost 9 years since my last exposure to C/C++. And I've never worked with Java. I'm coming from Delphi. In Delphi, you didn't need to put in the parens if the procedure or function didn't expect arguments.
Derek
|
|
|
|
|
I'm not usually one to complain, but I'd like to say publicly that I despise writing SQL statements using C# strings. In fact, the whole ADO.NET model really stinks, very tedious and hugely error-prone.
I mean, calling a simple stored procedure with a few arguments is a royal pain:
SqlConnection connection = new SqlConnection(...);
string commandText = "MyStoredProcName";
SqlCommand command = new SqlCommand(commandText, connection);
SqlParameter param = new SqlParameter("@param1", [database type], [data type size], [source column]...);
param.Value = 5;
SqlParameter param2= new SqlParameter("@param2", ...);
param2.Value = someGuid;
command.Parameters.Add(new SqlParameter[]
{
param1,
param2
});
try
{
connection.Open();
object returnValue = command.ExecuteScalar();
return (int)returnValue;
}
catch(SqlException)
{
...
}
All this for calling a single stored procedure! And refactoring -- refactoring is tedious because all the code is strings. Error prone, and no way to catch it at compile time.
So I was hoping one of you might know of some tool that either generates code like this automatically, and/or checks for the validity of code against a stored procedure. Is there anything like this?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
Judah Himango wrote: // I sure hope the database guy doesn't change the stored proc name, or I'll be screwed!
Judah Himango wrote: // I sure hope the database guy doesn't change this stored proc parameter, or I'll be screwed!
Judah Himango wrote: // I sure hope the DBA doesn't modify the return type, or I'm screwed!
It sounds like the problem is more to do with team communication rather than ADO.NET. Would you like to suggest a way of working where your code would not be screwed by someone changing the stored procedure name, the parameters or the return type?
Judah Himango wrote: // Oh, great, boxing! Thanks ADO.NET!
How would you suggest it is done? Given the roundtrip time of calling a stored procedure on a database the additional time it takes to box this value is negligable. When running a SQL Command you have much greater performance problems to worry about than that piddling little thing.
Judah Himango wrote: All this for calling a single stored procedure! And refactoring -- refactoring is tedious because all the code is strings.
I write a DAO (Data Access Object) class to wrap this up neatly. Most of my public methods are just one or two lines long. All the rest is common enough to be sent to private methods to be called from the public one.
I've also experimented with using reflection to work out what should be built as I use a cradle-to-grave naming convention and my DAO class acts as a proxy to the stored procedures, so its public interface is basically a C# representation of the stored procedures.
Judah Himango wrote: So I was hoping one of you might know of some tool that either generates code like this automatically, and/or checks for the validity of code against a stored procedure.
I've not yet found a code gen tool that solved more problems than it created.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Colin Angus Mackay wrote: Would you like to suggest a way of working where your code would not be screwed by someone changing the stored procedure name, the parameters or the return type?
Sure: a tool that statically analyzes my code and the database code, making sure it's all synced and compatible. Or at very least, a tool that could generate ADO.NET code given a stored proc, view, etc. so that if major changes are made, it would just regenerate ADO.NET code to make it all work nicely again. My C# code would then fail at compile-time, rather than at run-time.
Colin Angus Mackay wrote: When running a SQL Command you have much greater performance problems to worry about than that piddling little thing.
Ha, that's true, but if you put this on a server where thousands of sprocs are being called, this contributes to more garbage collection, degrading performance. I would suggest a generic class for this; after all, most sproc parameters are value types (come to think of it, the only time I use reference types would be when dealing with text or binary data). I suppose some of the marshalling and casting to get this to work might offset the benefits, if it's at all technologically possible.
|
|
|
|
|
I'm working on a web based project that uses a Web Service to read from and write to an access database on the server.
I have compiled the service and it works with database, seemingly, fine when i switch anon' access to the web service OFF.
My problem is that switching off anon' access means my web app page can no longer talk to the web service
I know this is probably dead simple and a stupid oversite but im having no luck trying to resolve this.
I'm also petty green when it comes to all the web based permisions stuff.
The Web service wont alllow anon users (It wont work with the DB otherwise)
It accepts all users, authenticates in Windows mode and impersonates = true
The web app: accepts all users, authenticates in Windows mode and impersonates = true
Any help with this would be very welcome.
Thanks.
|
|
|
|
|
Hi,
How can I add arrows like the ones that appear in DAP or IDM. Which says "Show Details" and contains an arrow that points downwards and when you click on it, it changes to "Hide Details" and the arrow points upwards... I hope my question is clear
There is no patch for ignorance
|
|
|
|
|
The test way is to change the text of the button on the click event. This way you can toggle between the texts ">>Detail" to "Detail<<". The other way is to change the image on the button
this.buttonTest.Image = (Image)TestIcons.GetIcon("ShowDetails.ico").ToBitmap();
Live Life King Size
Alomgir Miah
|
|
|
|
|
Alomgir Miah wrote: this.buttonTest.Image = (Image)TestIcons.GetIcon("ShowDetails.ico").ToBitmap();
Is 'TestIcons' an ImageList??
There is no patch for ignorance
|
|
|
|
|
Can anybody help me how can i uninstall a software pesent in the remote system?.thanks in advance
|
|
|
|
|
private void func1()
{
TP=1000000;
start_volumn=new double[TP];
pre_volumn=new double[TP];
post_volumn=new double[TP];
best_end_volumn=new double[TP];
}
For some reason, I need call function func1 many times. what will happen to the gabage collection system of C#? at the second time to run start_volumn=new double[TP]; will the memory allocated by the first time running start_volumn=new double[TP] by released?
THX
|
|
|
|
|
The memory will be collected when the garbage collector lazily collects. You can force a collection via GC.Collect(), however this is not recommended in typical situations.
|
|
|
|