|
In C# declare the variable as a static member of one of the classes. It can be accessed by classname.variable name in the other classes.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
A much better way would be to pass the variable to each form as opposed to decalring it as global. For several "global" types declare a class and pass it to each form.
|
|
|
|
|
Hi,
I have a base Form and a base TextBox control. I have derived my Form and TextBox control from the base classes. In the base class of form, I am adding EventHandler for TextChanged Event of TextBox to do some generic operation like setting dirty flag. And again in the Derived View I am using TextChanged Event of TextBox Control to enable/disable the OK button. I am opening the form in Modal form. When I close the Form, it is not getting cleanup from memory. I checked it in .NET Profiler. In the profiler it is showing me that TextChanged EventHandler is still referring the Form. I want to cleanup all EventHandlers on Closed event of the Form. Pls let me know how I can cleanup all EventHandlers for all Controls in the Form. IT IS URGENT. Please let me know.
|
|
|
|
|
If you're showing the form by calling it's .ShowDialog() method, you MUST call .Dispose() on it when you're done with it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am also calling .Dispose() after ShowDialog(). Still it is not helping...
|
|
|
|
|
You have to manually unsubscribe.
private void Subscribe()
{
otherForm.TextChanged += new TextChangedDelegate(thisForm_TextChanged);
}
private void Unsubscribe()
{
otherForm.TextChanged -= new TextChangedDelegate(thisForm_TextChanged);
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Actually the problem is that I don't know what all the EventHandlers each Derived Form is using. So it's become very difficult to remove all EventHandlers from each Derived Form manually. I just want to know if there is any way to remove all EventHandlers for all controls in the Form so that I can loop through all controls in the Form and Remove it in Base Form class. Please Help.
|
|
|
|
|
Hello everybody here!!!.
i would like to know how can i add new command to the run process of the windows os for example .
press the following
--------------------
start ---> run --->and type ---->cmd or regedit
it will open the MsDos or Registry of the Windows OS respectively but i want to add new command like this of my own is it some string key or entry in the registry that manages this and by the way yahoo messenger do the same when you expose one friend's email from yahoo online member directory, you will see the online icon and you press that icon with this simple html script:
<code>
<a href="ymsgr:sendim?the_Friend_nickname">the online icon</a>
</code>
and it is it it opens for you private window for chatting with that friend.
I want to add command of my own like this any body has any solutions for this please refer to me with an idea or even an article on this.
As i guess ! it is all related to enter new key value data in the registry in specific part with the extension of your program , but where i don't know any body can help me in this please ..
Thanks for your help.
Mess With The Best And Die Like The Rest
-- modified at 16:00 Friday 14th October, 2005
|
|
|
|
|
It is the path property in the environment that decides where the system will look for programs to run. Back in the days when the system was DOS based, the path was set in the autoexec.bat file. Nowadays you can change it from the properties of "My Computer". When you enter the name of a program in the start...run dialog or at a command prompt, the system first looks for the program in the paths specified in the path property.
The thing that yahoo messenger does is something completely different. "ymsgr" is a protocol, just like "http" or "ftp". It works pretty much as a file type, and the protocols are visible in the file type list in the folder options in Explorer.
Now I hope that you have a bit more information so that you can determine what it is you want to do, really.
---
b { font-weight: normal; }
|
|
|
|
|
Ok maybe I am going dumb here, but I cannot for the life of me figure this problem out. In the MSDE database there is a column called Slides. In that Slide table there is a Version column. Which is defined as a string. It contains data like 1.0.0. Well i am trying to create a typedataset where I just dragged and dropped the Slide table from the server explorer.
That being said, when I go in for the Fill command, I keep getting the InvalidCastException. I tried changing the column types to double etc...but no go. Any suggestion.
Thanks
Sameer
|
|
|
|
|
1- use float casting .
or
2- change the column data type into float numbers and tell us what did you get still having that problem or not ?
Mess With The Best And Die Like The Rest
|
|
|
|
|
Actually I am an idiot...the problem was in my DAL. When I wrote this function called
RunSqlReturnDS( string cmd , table )
well lets just say I hardcoded the table array position..i.e m_dataHolder.Tables[0].Rows..you get the idea.
So, it was returning rows from the previous run of the function.
|
|
|
|
|
Hello,
I have a ListView which has a small ellipsis button that I place dynamically.
The problem is I am not able to reposition the button when I scroll the Listview horizontally.
Any suggesstion is valuable to me.
Thanks
Alomgir Miah
Live Life King Size
-- modified at 14:02 Friday 14th October, 2005
|
|
|
|
|
Hi
I am in the process of developing a web application (well, kind of parital migration as the database storprocedures are going to be reused and the old app which was in vb6/asp is being re-written in ASP.NET) and had some questions with the data layers. I am using custom business entities to repesent business objects and these entities also have the CRUD methods for data access. I modelled it based on the Time Tracker Starter kit at http://www.asp.net and also the samples from enterprise library june 2005 version. I read numerous articles abt this and got confused.
I am not sure if it is a good approach to have the CRUD methods in the custom business entity or have it in a separate data layer component.
I have posted a sample code for a business entity that is used in my add.
Any suggestions / comments to make it a better solution would really be appreciated.
Thanks
Please
<br />
public class User<br />
{<br />
private string _oneWorldID;<br />
private string _lastName;<br />
private string _firstName;<br />
private string _middleInitial;<br />
private string _respDivName;<br />
private string _accessLevel;<br />
private string _activeInd;<br />
private int _respDiv;<br />
<br />
public enum Select<br />
{<br />
Active="Y",<br />
InActive="N",<br />
All=""<br />
}<br />
public User(string sOneWorldID)<br />
{<br />
OneWorldID = sOneWorldID;<br />
FirstName = LastName = MiddleInitial = string.Empty;<br />
RespDivName = ActiveInd = string.Empty;<br />
RespDiv = 0;<br />
}<br />
<br />
public User()<br />
{<br />
User(string.Empty);<br />
}<br />
<br />
public string OneWorldID<br />
{<br />
get {return _oneWorldID;}<br />
set {_oneWorldID = value;}<br />
}<br />
public string FirstName<br />
{<br />
get {return _firstName;}<br />
set {_firstName = value;}<br />
}<br />
public string LastName<br />
{<br />
get {return _lastName;}<br />
set {_lastName = value;}<br />
}<br />
public string MiddleInitial<br />
{<br />
get {return _middleInitial;}<br />
set {_middleInitial = value;}<br />
}<br />
public string RespDivName<br />
{<br />
get {return _respDivName;}<br />
set {_respDivName = value;}<br />
}<br />
public int RespDiv<br />
{<br />
get {return _respDiv;}<br />
set {_respDiv = value;}<br />
}<br />
public string ActiveInd<br />
{<br />
get {return _activeInd;}<br />
set {_activeInd = value;}<br />
}<br />
public string AccessLevel<br />
{<br />
get {return _accessLevel;}<br />
set {_accessLevel = value;}<br />
}<br />
<br />
public bool GetUsersDetails()<br />
{<br />
bool bUserFound = false;<br />
Database sqldb = DatabaseFactory.CreateDatabase("GatewaySQL");<br />
DBCommandWrapper sqlCommandWrapper = sqldb.GetStoredProcCommandWrapper("sp_Select_User_List");<br />
<br />
Utils.BuildParameters( sqlCommandWrapper, <br />
Utils.ParameterCount.SingleParameter,<br />
new object[]{"@ONW",System.Data.DbType.AnsiStringFixedLength,4,ParameterDirection.Input,this.OneWorldID}<br />
);<br />
<br />
using (IDataReader dr = sqldb.ExecuteReader(sqlCommandWrapper))<br />
{<br />
while (dr.Read())<br />
{<br />
this.LastName = dr.GetValue(1).ToString();<br />
this.FirstName = dr.GetValue(2).ToString();<br />
this.MiddleInitial = dr.GetValue(3).ToString();<br />
this.RespDivName = dr.GetValue(4).ToString();<br />
this.ActiveInd = dr.GetValue(5).ToString();<br />
this.AccessLevel = dr.GetValue(6).ToString();<br />
bUserFound = true;<br />
}<br />
return bUserFound;<br />
} <br />
}<br />
<br />
<br />
public static UsersCollection GetUsers(int iRespDiv, User.Select select)<br />
{<br />
Database sqldb = DatabaseFactory.CreateDatabase("GatewaySQL");<br />
DBCommandWrapper sqlCommandWrapper = sqldb.GetStoredProcCommandWrapper("sp_Select_User_List");<br />
<br />
string sActiveInactiveInd = "";<br />
switch (select)<br />
{<br />
case User.Select.Active:<br />
ActiveInactiveInd = "Y";<br />
break;<br />
case User.Select.InActive:<br />
ActiveInactiveInd = "N";<br />
break;<br />
}<br />
<br />
Utils.BuildParameters( sqlCommandWrapper, <br />
Utils.ParameterCount.MultipleParameters, new object[]{"@iRespDiv",System.Data.DbType.Int32,4,ParameterDirection.iRespDiv},<br />
new object[]{"@ActiveInactiveInd",System.Data.DbType.AnsiStringFixedLength,1,ParameterDirection.Input,sActiveInactiveInd}<br />
);<br />
<br />
using (IDataReader dr = sqldb.ExecuteReader(sqlCommandWrapper))<br />
{<br />
UsersCollection users = new UsersCollection();<br />
while (dr.Read())<br />
{<br />
User usr = new User();<br />
usr.OneWorldID = dr.GetValue(0).ToString();<br />
usr.LastName = dr.GetValue(1).ToString();<br />
usr.FirstName = dr.GetValue(2).ToString();<br />
usr.MiddleInitial = dr.GetValue(3).ToString();<br />
usr.AccessLevel = dr.GetValue(4).ToString();<br />
usr.ActiveInd = dr.GetValue(5).ToString();<br />
}<br />
return users;<br />
} <br />
}<br />
<br />
public void InsertUser(string sUpdt_User_OneWorldID)<br />
{<br />
try <br />
{<br />
using (new EntServicesProvider())<br />
{<br />
Database sqldb = DatabaseFactory.CreateDatabase("GatewaySQL");<br />
DBCommandWrapper sqlCommandWrapper = sqldb.GetStoredProcCommandWrapper("sp_Insert_User");<br />
<br />
Utils.BuildParameters( sqlCommandWrapper, <br />
Utils.ParameterCount.MultipleParameters,<br />
new object[]{"@OWN",System.Data.DbType.StringFixedLength,9,ParameterDirection.Input,this.UserID}, <br />
new object[]{"@firstName",System.Data.DbType.StringFixedLength,40,ParameterDirection.Input,this.FirstName},<br />
new object[]{"@lastName",System.Data.DbType.StringFixedLength,40,ParameterDirection.Input,this.LastName},<br />
new object[]{"@middleInitial",System.Data.DbType.StringFixedLength,40,ParameterDirection.Input,this.MiddleInitial},<br />
new object[]{"@accessLevel",System.Data.DbType.StringFixedLength,1,ParameterDirection.Input,this.AccessLevel},<br />
new object[]{"@activeInd",System.Data.DbType.StringFixedLength,1,ParameterDirection.Input,this.ActiveInd},<br />
new object[]{"@respDiv",System.Data.DbType.Int16,2,ParameterDirection.InputOutput,this.RespDiv} <br />
);<br />
<br />
using (IDbConnection connection = sqldb.GetConnection())<br />
{<br />
connection.Open(); <br />
sqldb.ExecuteNonQuery(sqlCommandWrapper);<br />
}<br />
SQLTransactionLog.InsertTransaction( "Insert",<br />
sUpdt_UserID,<br />
"SQL",<br />
"sp_Insert_User",<br />
this.Id,<br />
this.RespDiv.ToString(),<br />
"Secondary column contains User's Division ID." );<br />
<br />
ContextUtil.SetComplete();<br />
}<br />
}<br />
catch (Exception e)<br />
{<br />
ContextUtil.SetAbort();<br />
throw new Exception (e.Message);<br />
}<br />
}<br />
<br />
}<br />
<br />
|
|
|
|
|
How to use function of VB.NET in C#
for example: when i want to use IsNumeric function of VB.NET in C#.
Thanks
I tried so hard and got so far
|
|
|
|
|
I think this would work, haven't had time to test it though
add a reference to the Microsoft.VisualBasic.dll
Microsoft.VisualBasic.Information.IsNumeric( Object )
HTH
Russ
|
|
|
|
|
Well the crazy way would be
bool isnumeric = false;
try
{
Convert.Int32(Object)
}
catch
{
isNumeric = true;
}
//use the isnumeric now
|
|
|
|
|
Not quite...
the isNumeric=true; has to follow the Convert.ToInt32() .
Or use Double.TryParse() to test without having to throw excaptions.
Regards,
mav
|
|
|
|
|
I'm trying to get MSMQ to talk to my application.
I will be using com+ when i'm done, but for the moment i'm using a standalone exe, just to get the idea of things.
I've set up the app using static void Main(Args[]) and i can get the parameters. Apart from the message body. I've converted the string that i get passed to the correct format but i'm missing the final character. It's using xmlserialization for the moment so i've just added a > on the end and my code works, but i'll be switching to binary later so i won't be able to predict what the character is meant to be.
Anyone got any idea how this should work?
Thanks
Russ
|
|
|
|
|
Hello,
I need to create a IE Extension in C#. I want to add a button to IE standard toolbar and then make IE call the DLL when button is clicked.
I have started with the following code
<br />
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]<br />
public struct OLECMDTEXT<br />
{<br />
public uint cmdtextf;<br />
public uint cwActual;<br />
public uint cwBuf;<br />
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=100)]public char rgwz;<br />
}<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct OLECMD<br />
{<br />
public uint cmdID;<br />
public uint cmdf;<br />
}<br />
[ComImport,<br />
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]<br />
public interface IOleCommandTarget<br />
{<br />
void QueryStatus(ref Guid pguidCmdGroup, UInt32 cCmds,<br />
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] <br />
OLECMD[] prgCmds, ref OLECMDTEXT CmdText);<br />
void Exec(ref Guid pguidCmdGroup, uint nCmdId, uint nCmdExecOpt, <br />
ref object pvaIn, ref object pvaOut);<br />
}<br />
[ClassInterface(ClassInterfaceType.None),<br />
ComSourceInterfaces(typeof(COM_Events))]<br />
public class COMAddin: IOleCommandTarget<br />
{<br />
public void QueryStatus(ref Guid pguidCmdGroup, <br />
UInt32 cCmds, OLECMD[] prgCmds, ref OLECMDTEXT CmdText)<br />
{<br />
}<br />
public void Exec(ref Guid pguidCmdGroup, uint nCmdId, <br />
uint nCmdExecOpt, ref object pvaIn, ref object pvaOut)<br />
{<br />
}<br />
}
But I don't know what to do next.
I know that I have to add a key in HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Extensions.
And I have to somehow register the COM DLL (regasm?), and create some GUIDs. I don't know where to put those GUIDs, in which class, should I do it over attributes or over assembly... This is a managed DLL, all articles that I find on the net are related to plain native C++. And I need to get the IE Document data somehow (IHTMLDocument2 or something?), but that is not primary here.
Can anyone point me to a good article for this, or help me directly?
Thank you in advance,
Milos
|
|
|
|
|
I have a picture box inside a panel control. AutoScroll property for the panel is set to true. picture box is large enough to show the horizontal or vertical scrollbars of the panel control.
I am trying to Crop the picture box (with RubberBand effect).
When I bring the mouse near the Right Or Bottom Edge of the panel control, the panel control does not scroll.
Can somebody help scroll the panel control?
A code snippet will surely save me some time.
|
|
|
|
|
I'm not certain but I suspect you'll need to do this manually. I can't think of a way to do so without using a 2nd thread though.
My thought is using the MouseMove event, getting the mouse position out of the event args, and if it's within N pixels of the border, starting a thread to scroll the image one pixel N times/sec. IF the mouse isn't within N pixels terminate the scrolling thread (if neccesary).
|
|
|
|
|
I'm using an fsw to monitor a shared save directory for my application, the problem is that when my app saves the datafile the Changed event fires 4 times for the file.
-- modified at 9:51 Friday 14th October, 2005
Make that upto 4 times, with a larger file it's only firing twice.
|
|
|
|
|
Which events and how many times they fire depends HEAVILY on how your application is saving the file. For example, when you open a Word document, it makes a copy of the original file, with a temp filename, and opens the copy. When you save your changes, the file is saved to the copy, then the original file is deleted and the copy renamed to the original filename.
There are no settings to filter out multiple firings of the events.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok. The update I'm doing doesn't cause enough of a performance hit to matter, I was just worried I was doing something wrong.
The files are xml, and except for xml version descriptor, and a comment are written entirely by an xml serializer so there's not much I can do to influence the write behavior.
|
|
|
|
|