|
Regards everybuddy,
Except timer method, how can I monitor a variable (for example a string) and call a method as soon as and each time it changes?
Thanks for any note and best wishes
-nSun
---
"Art happens when you least expect it"
|
|
|
|
|
I don't think you can attach an event to a variable in C#.
Of course you can theoritically create your own variable class which raises an event everytime it is changed.
However, I probably will just create a property for the variable which will call a method every time it is set.
Create your class if you need to use many variables, otherwise create a property.
Hope it helps.
|
|
|
|
|
Yes, Propert method is greate but in some cases creating a new class will be more effective. Thanks buddy
---
"Art happens when you least expect it"
|
|
|
|
|
Yes, Property method is greate but in some cases creating a new class will be more effective. Thanks buddy
---
"Art happens when you least expect it"
|
|
|
|
|
did you try making it a property (with get & set accessors that you can put whatever code you want into) or is that not suitable for what you want to do?
|
|
|
|
|
It seems it is the best choice in many cases. Thank you for your comment allancto.
---
"Art happens when you least expect it"
|
|
|
|
|
do someone know any Decompiler witch can decompile all dll files for c#?
thank u for help
|
|
|
|
|
|
Hey, I didn't know it did decompilation also! I oughta take a look, as Anakrino doesn't work on Win98, and Reflector might.
|
|
|
|
|
And it works! Thanks Nick!
|
|
|
|
|
NP Maybe it will speed development of the FLUID UI Toolkit?
-Nick Parker
DeveloperNotes.com
|
|
|
|
|
|
I need a horizontal tree control that would look like all the trees one sees in data structures textbooks, but have all the usual functionality (check boxes, drag/drop, etc.) Does such a thing exist?
The root would be center/top. Nodes would grow down to the left or right. Leaves would all be at the bottom.
How hard would it be to convert a std tree control into a horizontal one?
|
|
|
|
|
It would be very hard - and probably incredibly stupid - to make the "standard" tree control do such a thing. First of all, the .NET tree control is actually the SysTreeView32 common control in Windows, wrapped in a class for easy use with .NET. With this in mind, you have to go very low-level to change such behavior.
Since you're changing so much, however, it'd be much easier to do this from scratch in a completely managed solution. What you're describing, however, is common in organization charts. You could try searching for an existing organization chart control in .NET, which may help in constructing a more generic tree with the behavior you want. I can't think of any off-hand, but I'm willing to bet there's a few around - perhaps even here on CodeProject.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
That's an excellent tip. Thanks!
Dave
|
|
|
|
|
I think an org chart control would do what I need. I searched on Google and CodeProject, and I only found one org chart component: http://www.anextech.com/AnexTree.htm
If anyone has other suggestions, I appreciate them. I don't mind purchasing a good control, but I would like to get source code with it. The above control doesn't include source. Otherwise, it's pretty much what I was looking for.
Thanks.
|
|
|
|
|
I have a datagrid with some columns in it. I want to format a column in it which has only intergers (length <=8) in this way: xxx-xxxxx; where x is any digit. Is it possible to use the girdcolumnstyles' format property for this? If yes, how? If no, what should i do?
|
|
|
|
|
If you used a BoundColumn with your datagrid, you could use the DataFormatString property. There are some good examples in the DataFormatString help.
|
|
|
|
|
This code works in a "console" app, but when I place it in a COM+ serviced component, I got "E_NOINTERFACE" exception when I called OleDbAdapter.Fill(..)
public void AuthenticateUser(string username, string passwd, ref int retcode)
{ //AuthenticateUser
int count = -1;
string db_username;
string db_passwd;
int db_numlogin;
string connString;
OleDbConnection connUsers;
OleDbDataAdapter daUsers;
DataSet dsUsers;
EventLog log = new EventLog("Application");
log.Source = "AccessDbMaster";
try
{ //try block
retcode = -1;
connString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Program Files\AppAlgo\ComPlusServiceDemo\datasource\users.mdb; User ID=Admin; Password=";
connUsers = new OleDbConnection(connString);
daUsers = new OleDbDataAdapter("SELECT * FROM Users WHERE username='"+ username + "' AND passwd='" + passwd + "'", connUsers);
dsUsers = new DataSet();
daUsers.Fill(dsUsers, "Users");
count = dsUsers.Tables["Users"].Rows.Count;
if(count==0) {
log.WriteEntry("AccessDbMaster authentication failed. User not found");
return;
}
foreach(DataRow user in dsUsers.Tables["Users"].Rows)
{
db_username = user["username"].ToString();
db_passwd = user["passwd"].ToString();
db_numlogin = (int) user["numlogin"];
retcode = db_numlogin; //return value
//Increment number of login:
db_numlogin++;
user["numlogin"]=db_numlogin;
}
OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(daUsers);
daUsers.Update(dsUsers, "Users");
connUsers.Close();
} //try block
catch(Exception err)
{
log.WriteEntry("AccessDbMaster authentication failed. Info: " + err.Message);
retcode=-1;
}
return;
} //AuthenticateUser
Error message is not very descriptive: "No error information available: E_NOINTERFACE(0x80004002)."
I'm suspecting that it's got to do with COM+ security. I checked identity using COM+ Admin Tool. The application, and all COM+ apps in question, runs under SYSTEM account (Administrators). Impersonation level is "Impersonate" and "Packet"... Any idea? Thanks!
|
|
|
|
|
Hi, I'm writing a custom scroll bar control. My custom scroll bar control uses transparency, and has two button children that also have transparency. The background of the main window beneath my button located at (0,0) on the scroll bar and the background beneath the main scroll bar are fine. For some reason however, the background of the button at (0,30) in the scroll bar (the down button) has the main window background behind it offset by 30 pixels downward! It seems that a transparent window within a transparent window will have the shown background offset by its position within the parent transparent window.
I think I have located the source of this problem.. In the OnPaint method that is called to draw the background behind the transparent scroll bar which is behind the transparent button, somehow the e.Graphics.Transform.OffsetY is 0 when in the corresponding OnPaintBackground that was called just before it the e.Graphics.Transform.OffsetY was -30! I believe this is why my image is being offset, but I don't know why it's happening?
I know it's a complex problem, but can anyone help me? I've been working at it for about 6 hours now!
Thanks!
|
|
|
|
|
Ok, well, I've found a solution to my problem. After my hours and hours of debugging I've concluded that it's either a bug with the framework or something else beyond the scope of my code that is happening.
I have solved the problem by drawing the background of the scroll bar control manually rather than calling the default OnPaintBackground.
Here is the code that fixed it in case anyone is interested:
protected override void OnPaintBackground(PaintEventArgs e)<br />
{<br />
GraphicsContainer container = e.Graphics.BeginContainer(e.ClipRectangle, e.ClipRectangle, GraphicsUnit.Pixel);<br />
<br />
Rectangle rectBg = e.ClipRectangle;<br />
rectBg.Offset(this.Bounds.Left, this.Bounds.Top);<br />
e.Graphics.TranslateTransform(-this.Bounds.Left, -this.Bounds.Top);<br />
InvokePaintBackground(this.Parent, new PaintEventArgs(e.Graphics, rectBg));<br />
InvokePaint(this.Parent, new PaintEventArgs(e.Graphics, rectBg));<br />
<br />
e.Graphics.EndContainer(container);<br />
}
Any improvements to this method are appreciated.
|
|
|
|
|
How can I request a web page using POST while passing some variables? Like I want to access
http://www.localhost.com/info.aspx
with POST and with variables info=0 and set=1 ?
I have tried stupid HttpWebRequest BUT it is NOT WORKING ... I posted the question few days back BUT nobody answered it... GURU PPL where ARE YOU???
me doing this..
<br />
string lcUrl = "http://localhost/test.php";<br />
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);<br />
<br />
<br />
string lcPostData = "info=" + System.Web.HttpUtility.UrlEncode("0") + "&set=" + System.Web.HttpUtility.UrlEncode("1");<br />
<br />
loHttp.Method="POST";<br />
<br />
byte [] lbPostBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData);<br />
<br />
loHttp.ContentLength = lbPostBuffer.Length;<br />
<br />
Stream loPostData = loHttp.GetRequestStream();<br />
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);<br />
loPostData.Flush();<br />
loPostData.Close();<br />
<br />
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();<br />
System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1252);<br />
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(),enc);<br />
<br />
string lcHtml = loResponseStream.ReadToEnd();<br />
Console.Write(lcHtml);<br />
loWebResponse.Close();<br />
loResponseStream.Close();<br />
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
Hmmm... Strange. This looks nothing like mine did...
Well, this worked for me:
Encoding enc = Encoding.GetEncoding("ISO-8859-1");
WebClient wc = new WebClient();
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
string request = "input_name=the_value";
byte[] requestBytes = enc.GetBytes(request);
byte[] responseArray = wc.UploadData(uriString, "POST", requestBytes);
string responseString = enc.GetString(responseArray);
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|
|
ahhh... you don know what you have just done! Gave me life... YES...Thank you very much... a thousand for you; to fill your room with fregrence...
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
do you know how to tell what webserver a site is running?
/\ |_ E X E GG
|
|
|
|