|
Thanks a bunch. I'm going to try this right away!
Right now I'm only writing one such extender, but otherwise it would be a good idea.
BR
Christian
|
|
|
|
|
Well. It didn't quite cut it. I'm wondering if it's because of the fact that the extender is in a dll that the windows application is referencing?
-- modified at 16:53 Thursday 25th May, 2006
When I use it, it returns "System.Windows.Forms.Button".
|
|
|
|
|
The following code (just a simple example):
using System;
using System.Windows.Forms;
namespace PiLogic.Windows.Forms
{
public class Test : Button
{
public string GetName()
{
return this.GetType().FullName;
}
public static void Main(string[] args)
{
Test test = new Test();
Console.WriteLine(test.GetName());
}
}
}
Displays the following text when run:
PiLogic.Windows.Forms.Test
So I don't know why you get System.Windows.Forms.Button, you sure your using this and not base ?
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
The code is in an Extender. The extender gets a reference to the control as an object. The IExtenderProvider class is in a different assembly than the Button object. The dll does not reference the project with the form and button, as that would create circular references. I think that the IExtenderProvider evaluates the type to one that it's aware of.
This is not my actual code, but I think you get the idea.
bool IExtenderProvider.CanExtend(object o)
{
Console.WriteLine(o.GetType().FullName);
}
The button object is actually a System.Windows.Forms.Button type. Therefor I add the name of the Form that is parent of the IExtenderProvider to the name of the button. This will give me Form1.button1, but I also need the namespace that Form1 belongs to. If I do GetType().FullName on the form I get System.Windows.Forms.Form, but the actual type of the form would be WindowsApplication1.Form1.
Do I make sense?
/Christian
|
|
|
|
|
I get what you're trying to do now. The only way I can think of at the moment is you're going to have to create a pile of recursive functions to walk up through the button's parent hierarchy to extract the name. GetType () will just extract the base type of the button.
You can use the Name property of the control, and then iterate backwards to it's parent form and the parent form's namespace etc. But I think that this is a bad way to do it. As I said, I can't think of another way at the moment, I'll keep trying but might I suggest trying to find another way around this. Can you store the actual references rather than the names? Then (I'm guessing now ) if you need to compare the two objects you can use == to do it.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Thanks for your input. I have already prepared a workaround, as I don't want this issue to tie me up any longer. I'm using the form name and the control name only.
I can understand why GetType().Name returns System.Windows.Forms.Button for the button, because my button is only an instance of that type. The form on the other hand is an instance of a custom made class that inherits from System.Windows.Forms.Form. Because of this, the function should return the name of my class that the object is instanciating.
Again, thank you for your effort.
/Christian
|
|
|
|
|
Hi Guys,
I cant find any section for Biztalk server in the Code Project.
Is it not relevant here?
Or should we have it?
I strongly believe that we should have a section for Biztalk so that we can share Biztalk related project samples and information.
Thanks
Firoz Ozma
..:: firozOzman ::..
http://spaces.msn.com/members/firozozman/
|
|
|
|
|
i m very bad in c# programming
can anyone tell me good websites or books to learn c# programming.
plzzzzzzzzz its very urgenttt
|
|
|
|
|
lucky1234560 wrote: can anyone tell me good websites or books to learn c# programming.
This one!
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
|
Has anyone had to find the virtual application root inside a javascript? I'm having some trouble with it. In the past, we have been able to use:
var spellURL = "../CommonPages/SpellCheck.aspx";
inside our spell.js script. But we recently added a new level of subdirectories. So SOMETIMES we need another "../" in order for js to find the aspx page. So instead of trying to use relative paths, does anyone know the js equal of "~"??
fyi - i didn't design the new level of directories. That was PJ (Pre-Jessica)
Thanks, Jessica
|
|
|
|
|
FYI - ended up using
/AppName/CommonPages/SpellCheck.aspx
Thanks, Jessica
|
|
|
|
|
I have this as part of building an array of pictureBoxes:
excuse the .<. below because without the .'s the rest of the line was cut off
for (i=0; i.<.MaxPics; i++)
{
ACTHumbBox[i] = new PictureBox();
...
ACThumbBox[i].MouseClick += new MouseEventHandler(ACThumbBox_MouseDown);
...
}
private void ACThumbBox(object sender, MouseEventArgs e)
{
blah blah blah
}
How can I determine which pictureBox triggered the event?
-- modified at 14:56 Thursday 25th May, 2006
|
|
|
|
|
private void ACThumbBox(object sender, MouseEventArgs e)
{
for (i = 0; i < ACTHumbBox.Length; i++)
{
if (ACTHumbBox[i] == (PictureBox) sender)
{
//... Found clicked picture box
break;
}
}
}
|
|
|
|
|
Thanks a lot - just what I needed.
|
|
|
|
|
From a quote:
"C# is a simple, modern, object
oriented, and type-safe programming
language derived from C and C++. C#
(pronounced "C sharp") is firmly planted
in the C and C++ family tree of
languages, and will immediately be
familiar to C and C++ programmers. C#
aims to combine the high productivity of
Visual Basic and the raw power of C++."
If C# is a simpler version of C and C++, shouldn't it be called C Dull?
Maybe the VB portion redeems it from the doldrums...?
Just wondering.
Take Care
God Bless... Feedscrn
+------------------------------+
| The screen is hungry, Feed It! |
+------------------------------+
|
|
|
|
|
Are you just trying to ruffle feathers? What is the point of this posting?
feedscrn wrote: Maybe the VB portion redeems it from the doldrums...?
'Maybe' being the imperative word.
Josh
|
|
|
|
|
After reading more.. C# really is not connected to C++ in any way. So many things in programming are either built onto C++ or the C++ name... using the popularity of C++ to its advantage (and confusing C++ programmers at the same time).
Take Care
God Bless... Feedscrn
+------------------------------+
| The screen is hungry, Feed It! |
+------------------------------+
|
|
|
|
|
Hello,
I am using the following piece of code to save data to my database:
<br />
SqlDateTime date = DateTime.Now; <br />
SqlCommand myCommand2 = new SqlCommand("INSERT INTO orders (date,customerid,productid,sum) VALUES ('" + date + "'," + index + ",'" + productid + "','" + aantal + "')", connect); <br />
myCommand2.ExecuteScalar();<br />
the date-field in the database has the property datetime.
When i try to run the query, he always gives following error:
<br />
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.rnThe statement has been terminated.<br />
I tried to use DateTime.Now directly in the query, but it still gives the same error, also writing a date by hand (in the values-field in the query) gives an error.
When I write a date (exactly the same format as the one above) directly in the database (without a query), i have no errors what so ever.
Can somebody help?
Thanks!
|
|
|
|
|
Have you had a look at at the actual SQL string produced by your string concatenation? I'm guessing there's a format mismatch, maybe due to some regional settings or something. (Often a problem when putting datetimes into the db like this.)
A safe and easy way to fix this would be to use parameters in your SQL query:
string query = @"
INSERT INTO orders (date,customerid,productid,sum)
VALUES (@date, @customerid, @sum)
";
SqlCommand cmd = new SqlCommand(query, con);
cmd.Parameters.Add("@date", DateTime.Now);
cmd.Parameters.Add("@customerid", customerid);
cmd.Parameters.Add("@sum", sum);
cmd.ExecuteNonScalar();
|
|
|
|
|
Thanks, that solved my problem!
|
|
|
|
|
SqlServer likes to see a char dates in a specfic format. You will have to experiment a little but from memory it likes:
01/01/98
OR
01/01/98 23:59:59.999
It is not very tolerant with other formats.
Try date.ToString("dd/MM/yyyy HH:mm:ss.000") in place of date
BTW: I normally let the SQL Server set a DateTime stamp by using GetDate() in place of '" + date + "' . It will usually have a more accruate time then a workstation (at least it will be a common clock). There is also GetUTCDate() for when your users are in different time zones.
|
|
|
|
|
Michael Potter wrote: Try date.ToString("dd/MM/yyyy HH:mm:ss.000") in place of date
date.ToString("s"); works for me as well. This put a "T" between the date and the time, but that seems to be accepted by MySQL in my case.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have written a function called MyFunction() in a class library called TestClassLibrary. Now supppose that at design time a user creates an object of this class and presses dot(.) with the object to view the related functions, properties etc in the auto context menu. I want that whenever the user selects MyFunction() in that auto context menu, a little description of MyFunction() is displayed as tooltip as it appears with the built in functions. How to do that?
Thanks in advance
|
|
|
|
|
You need to apply a 'Description' attribute to the function. Here is an example:
[Description("Override this method if anything needs to be saved other than the ActivePanel.")]
public virtual bool CanClose()
{
if (this.ActivePanel != null)
return ActivePanel.CanClose();
else
return true;
}
|
|
|
|