|
Hi!
Trying to set the checked property in the CheckedChanged event doesn't work directly, but with a litte trick you can achieve this:
Call a delegate for resetting the Checked state using BeginInvoke() , so that the code is executed after the CheckedChanged event handler is through.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I'm trying to get the namespace that a class resides in within a static method of that class.
this.GetType().Namespace; works if the method is not static but obviously this is not valid in a static method.
Edit:
I've found that this way works but I'm sure there's a better way!
private class dummy
{ }
static string GetNamespace()
{
dummy temp = new dummy();
return temp.GetType().Namespace;
}
Dave
modified on Monday, March 3, 2008 7:52 AM
|
|
|
|
|
You can simply use typeof(MyClass).Namespace.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Thanks Tom, it works and will solve my problem but I was looking for a more general way if there is one.
The static method must already be in a class, so surely it should know what MyClass is without me having to specify it?
Dave
|
|
|
|
|
This works!
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Namespace;
Dave
|
|
|
|
|
You could always do this with the StackFrame. Here's a quick sample:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace TestApp
{
class Program
{
static void Main(string[] args)
{
StackFrame sf = new StackFrame();
Console.WriteLine(sf.GetMethod().DeclaringType.Namespace);
}
}
} GetMethod has a property called DeclaringType which returns the type of the class the method is implemented in, and from there it's trivial to find the namespace.
|
|
|
|
|
Cheers Pete, I actually found and posted the solution at the same time as you!
I used System.Reflection.MethodBase.GetCurrentMethod() instead of StackFrame.GetMethd()
Are there any advantages of either one?
Dave
|
|
|
|
|
DaveyM69 wrote: Cheers Pete, I actually found and posted the solution at the same time as you!
I used System.Reflection.MethodBase.GetCurrentMethod() instead of StackFrame.GetMethd()
Are there any advantages of either one?
Well, the StackFrame always implicitly returns MethodBase information, plus it returns line and file information if it's a debug build (obviously no line/file info should be returned for a release build). So, no real benefit of either one.
|
|
|
|
|
Hi,
I need to display the contents of a spreadsheet document in a listView or dataGrid. The code that I have opens the document, but only prints the first column's data. I need it to print all the data. I also need to add a new column in the spreadsheet as it loads. Please help!
Regards,
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
|
Hi,
thanks for the reply, but I saw this article and the listView does not display the contents of my spreadsheet properly. It only displays the first column.
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
Good Afternoon All
An new in C#, i have been doing Ado.net in vb.net. i want to use a Stored Procedure to do my database work, and i want to tell my command object that we are going to use a StoredProcedure. if i try this
<br />
<br />
cmdselect.CommandType = CommandType = StoredProcedure;<br />
<br />
I get an Exception that says
The Name StoredProcedure does not Exists in the current context
i have googled and my line looked ok, but i dont know what is wrong with this line
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
|
hi Thanks for your Reply
like this
<br />
cmdselect.CommandText = "get_me";<br />
<br />
cmdselect.CommandType = CommandType = StoredProcedure;<br />
"get_me" is the name of the Procedure.
and this is how i wrote my code, what is Wrong ?
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Vuyiswa wrote: and this is how i wrote my code, what is Wrong ?
Since this code would generate a compiler error, surely the error message would be able to pinpoint where the error is.
Try:
cmdselect.CommandType = CommandType.StoredProcedure;
Note the dot instead of the second equals sign.
|
|
|
|
|
Thanks it worked
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi!
The first place to look for parameters should be the documentation - MSDN still is the authority to ask.
Try explaining what your cmdselect.CommandType ... line does (not what you want it to do, but what the meaning of the statements you've written is!).
You'll see that the two assignments you're performing are nonsense.
StoredProcedure is an enum value and you have to tell which enum it's a part of.
Btw., you don't get an Exception but a syntax error during compilation - that's a huge difference!
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks man i saw the Problem
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
//Try the ff:
cmdselect.CommandType = System.Data.CommandType.StoredProcedure;
cmdselect.CommandText = "Name_Of_StoredProcedure";
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
Thanks man it Worked
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Glad to know
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
Thanks Bro
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
this is my suggestion check it out. the line should be
cmd.CommandType = CommandType.StoredProcedure;
|
|
|
|
|
Thanks i get your point
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
i'm using C#2005
i need to doing my two sqldatadpaters or more then in one transaction , and when happend error rollback all operation .
123
|
|
|
|