|
private void button1_Click(object sender, EventArgs e)
{
Button buttonNew = new Button();
buttonNew.Location = new Point(button1.Left + button1.Width +25, button1.Top );
buttonNew.Name = "buttonNew";
buttonNew.Size = new Size(130, 26);
buttonNew.Text = "buttonNew";
buttonNew.Click += delegate(System.Object o, EventArgs eArgs)
{ MessageBox.Show("new button clicked"); };
this.Controls.Add(buttonNew);
}
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I'm writing label-like control but not inheriting from anything.
And so I'm trying to add mouse events like MouseClick..
I read somewhere to put:
public delegate void MouseEventHandler(object source, int clickCount);
public event MouseEventHandler MouseClick;
public void OnMouseClick(object source, int clickCount) {
MessageBox.Show("clicked");
}
but thad doesn't seem to work..
I tried searching for it but all i found was inherited controls overriding these events..
life is study!!!
|
|
|
|
|
not registering events means not capturing events
SkyWalker
|
|
|
|
|
hello;
i want to catch that user double clicks on filled cells on datagrid but there is no event for this, is there any idea for handle it!
thanks
|
|
|
|
|
And one datagrid there is a cellcontentdoubleclick event but on other datagird doesnt exist.
On second datagrid i have initilazed datacolumns manually from properties. is that problem
|
|
|
|
|
If I remember correctly, the double click is actually broken down into 2 clicks: a click for the datagrid and another one for the datagrid cell. To achieve what you want, you either use a context menu (allowing the user to do multiple things, among them the action required by your double click), or you extend the datagrid class and try to capture the double click event.
SkyWalker
|
|
|
|
|
hi thanks for your reply
my problem is, datagrid doesnt have cellcontentdoubleclick but datagridview has cellcontentdoubleclick. and i have to use datagrid. beucase i wrote 6,7 pages code i cannot change
Now how can i use context menu i didnt use it before
thanks
best regards
|
|
|
|
|
|
thanks
it is so usefull
|
|
|
|
|
In visual c++ the keys ctrl-f2 puts a little blue bookmark next to the current line of code. To return to this code a person just uses the f2 key.
How can I book mark code in the .net editor?
thanks;)
|
|
|
|
|
See Tools -> Customize -> Commands -> Edit
SkyWalker
|
|
|
|
|
|
Ctrl+K. BTW - this is not the right forum for this question. This should have been asked in the Visual Studio forum.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All
I'm new to C# multithreading and timers.
I've got the code below where I want to prevent the time from repeting itself when the argument passed is not of the string type.
If I uncomment Thread.Sleep(Timeout.Infinite) doesn't work and keeps writing to the console each second when I expected to be stopped.
Why it happens?
Do I have to call tmr.Change(Timeout.Infinit,0) from TimerMethod? This way tmr variable should be shared between the main thread and the thread for the timer and syncrhonization/locking should be involved. Does exist some function to call from TimerMethod from stop itself without referring the Timer object tmr?
Regards
manuStone
class TestTimers
{
public static void TimerMethod(object obj){
if (obj is string) {
String str = (String)obj;
Console.WriteLine(String.Format("Timer by at {0:N6} by {1}", _tmr_cnt, str));
Interlocked.Increment(ref _tmr_cnt);
}
else {
Console.WriteLine("Passed Wrong Argument");
//How to stop the timer here?
//Thread.Sleep(Timeout.Infinite); Doesn't work:why?
//Do I have to call tmr.Change(Timeout.Infinit,0) here?
}
}
public void CallToThread(){
tmr_clbck = new TimerCallback( ThreadFoos.TimerMethod );
tmr = new Timer(tmr_clbck, 5, 0, 1000);
}
private Timer tmr = null;
private TimerCallback tmr_clbck = null;
}
|
|
|
|
|
|
Thanks
I will start digging on it.
Regards
ManuStone
|
|
|
|
|
Hello.
I have an oracle connection and I'm trying to run a stored procedure.
The code for defining the parameters in C# is:
------------------------------
cmd.commandType = CommandType.storedProcedure;
//Parameter 1:
OracleParameter prm1 = new OracleParameter("c1",OracleDbType.VARCHAR2);
prm1.Direction = ParameterDirection.Output;
prm1.Value = '1';
cmd.Parameters.add(prm1);
//Parameter 2:
OracleParameter prm2 = new OracleParameter("c2",OracleDbType.VARCHAR2, 200);
prm1.Direction = ParameterDirection.Output;
cmd.Parameters.add(prm2);
cmd.ExecutenonQuery();
--------------------------------------
The stored Procedure in Oracle (10g) is:
create or replace procedure test (c1 in varchar2, c2 out varchar2) is
Begin
c2:='1';
End test
\
--------------------------------------
The error I'm having is:
"ORA-06502: numeric or value error:charecter string buffer is too small"
I saw that error in few sites but not something like my problem?
Any idea?
Thanks.
|
|
|
|
|
You have there:
prm1 = new OracleParameter("c1",OracleDbType.VARCHAR2)
Therefore, the default length is 256 (i think).
In prm2 = new OracleParameter("c2",OracleDbType.VARCHAR2, 200) you specify a length of 200.
Sometimes, 200 < 256
SkyWalker
|
|
|
|
|
Hi.
Thanks but thats not the problem.
I tried with size 200/256/300/100/500/10 and nothing worked.
I'm with VS2005 and I added refference to the ODP dll of oracle.
What I did manage to do is to give the parameter a value:
prm3.value ='1'
and it worked but when i gave him string.Empty or didn't give him a value (since i want him to get the value from the SP) i got the same error.
Any idea?
|
|
|
|
|
Hi,
first, in your code snippet you set parameter c1 to direction output, whereas in the sp you declared it as input. maybe that's one part of the problem.
Second, Oracle behaves ... let's say different An empty string is the same as NULL in Oracle.
Martin
|
|
|
|
|
Hi martin and thanks for the reply.
Sadly it didn't helped
I tried use: pram3.value = null
but i got the same error.
Only if i give it a string (like: pram3.value = "str") it return the string.
can it be that the SP doesn't return a value and that way it fall?
It looks like a very simple SP.
(b.t.w The direction in my code is input for c1, I typed it wromg in here so that ok).
Do you any more ideas or a simple code for the SP and C# i can see.
I didn't find any oracle+c# on the net
Thank again.
|
|
|
|
|
Ok, next try I recognized that you are using ExecuteNonQuery. Maybe one of the other Executexxx methods will help. If not, I will try it here on our Oracle 9.0.2.
I must confess I never worked with the Oracle provider from Microsoft long. Better use Oracle's ODP.NET.
Martin
|
|
|
|
|
Arrr, It didn't do the trick.
I tried using executescaler instead and got the some error.
Also, I'm working with the ODP (I added the refference and the "using oracle.dataAccess.client") and with oracle 10g.
The problem is that I'm not even sure if the problem is from my C# code or from the oracle.
I know less about oracle so i took a very simple SP So there won't be any problem with that.
If You'll manage to get a result from a SP to a C# code I promise to add you to my holiday gift list 
|
|
|
|
|
Ok, I tried it with this code and it worked here (ODP.NET 10.2, Oracle 9g):
<br />
using ( OracleConnection conn = new OracleConnection( connString ) )<br />
{<br />
conn.Open();<br />
<br />
OracleCommand cmd = conn.CreateCommand();<br />
cmd.CommandType = CommandType.StoredProcedure;<br />
cmd.CommandText = "TEST";<br />
<br />
OracleParameter parm1 = cmd.CreateParameter();<br />
parm1.Direction = ParameterDirection.Input;<br />
parm1.OracleDbType = OracleDbType.Varchar2;<br />
parm1.ParameterName = "C1";<br />
parm1.Size = 200;<br />
cmd.Parameters.Add( parm1 );<br />
<br />
OracleParameter parm2 = cmd.CreateParameter();<br />
parm2.Direction = ParameterDirection.Output;<br />
parm2.OracleDbType = OracleDbType.Varchar2;<br />
parm2.ParameterName = "C2";<br />
parm2.Size = 200;<br />
cmd.Parameters.Add( parm2 );<br />
<br />
cmd.ExecuteNonQuery();<br />
Console.WriteLine( parm2.Value );<br />
}<br />
HTH,
Martin
|
|
|
|
|
Hi Martin ,
Thanks. That help!
I still didn't compere between my code and your but I just run yours and it WORKED!
The only diffrent I saw in a quick glance was that I didn't use the
"OracleCommand cmd = conn.CreateCommand();"
but instead I use
"OracleCommand cmd = new OracleCommand("TEST", conn);"
Thats the only thing that i saw.
Any way, The importent thing is That your code work and now i can try it!
Thanks a lot for your patient and help
Regards,
Roy,
|
|
|
|