|
Thank you for your answer,
but is it possible to see the state of a file. I Means can I check if the file I want to copy was open, and if it is delayed my copy.
Thanks
Demo
|
|
|
|
|
Thank you for your answer,
but is it possible to see the state of a file. I Means can I check if the file I want to copy was open, and if it is delayed my copy.
Thanks
Demo
|
|
|
|
|
Well, an exception is being thrown, right? Use that to your advantage.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Does anyone know of an API for controlling the output of a surround sound eg. 5.1 system?
I want to be able to say: play this wave file through the left rear speaker only.
Thanks
-Matt
|
|
|
|
|
DirectX[^] - as an added bonus, 9.0 introduced managed assemblies for easy access for .NET languages.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yeah, I know. I tried using DirectSound under DirectX 9.0 but AFAIK you can't do what I want - localise a speaker.
The best you can do is set a sound source to be from an xyz position - but that won't localise a speaker.
-Matt
|
|
|
|
|
Hi there
Can anyone tell me how i can change the action of the
close button on the control box of the form.
i want to hide the form rather than to close it when
the close button is pressed.
VisionTec
|
|
|
|
|
Handle the Form.Closing event (or override the related method for derived classes), cancel it, and do something else:
public class MyForm : Form
{
protected override void OnClosing(CancelEventArgs e)
{
this.Hide();
e.Cancel = true;
base.OnClosing(e);
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I am wondering if you guys are binding controls directly to your win forms with datasets? The reason why I am asking is because back in VS 6 in good old VB, it was frowned upon to bind recordsets to controls. One it had an impact on performance. Two it bloated your app with MS behind the covers code. Is this still happening with VS .net now or has it got alot better? Are alot of you binding your controls directly to datasets?
Thanks,
JJ
|
|
|
|
|
We do it all the time and it's fine. Because of the nature of data-binding (such as discovery and the binding itself), it's bound to be a little slower than a tightly-coupled solution, but this can be improved greatly by using strongly-typed DataSet classes, which you can make using VS.NET with a DataSet item (right-click on project or project folder, select Add->Add New Item...->DataSet), or by creating an XML schema and using xsd.exe to generate a strongly-typed DataSet class from the schema (this is basically what VS.NET does, only it uses add-in code that works much the same way, if not used by xsd.exe). A big reason for this is because when you refer to columns by name, a lot of look-ups are performed (more than you might think - use ildasm.exe to view the IL for the System.Data assembly and the relevent classes). When you create a strongly-typed DataSet , those column indexes are known at run-time and binding is faster.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm using Strong typed datasets but I'm not binding them to controls other than a datagrid or treeview. So I should wire all controls on form.
Lets say 20 to 25 at most and this should be ok with performance of 25 to 50 users using the app?
Design spec:
10 Winforms - 20 to 25 controls on each
25 to 50 users
JJ
|
|
|
|
|
It would work well for me, but whether or not it works well for your requirements is something only you can judge.
Also, 25-50 people won't be using the app. 1 person will be using one application. 25 people will be using 25 separate instances of an application. Those instances querying against the RDBMS will work just fine on a decent DB machine so long as your queries are written correctly and take locking into account when necessary. That has nothing to do with bindings, which is done per instance of the application.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello all,
I am working on a project that requires the use of .NET remoting, however I am experiencing some strange issues and I wonder if anyone can help me.
I am exposing a preexisting object through the use of RemotingServices.Marshal
After setting up all of the appropriate ChannelServices, I expose the object via:
<br />
RemotingServices.Marshal(ObjName,"RemoteObjName");<br />
This object however has public properties which can be gotten or set. However, when I execute the following code:
<br />
ObjType remInt = (ObjType)Activator.GetObject(typeof(ObjType) ,"tcp://localhost:9555/RemoteObjName");<br />
<br />
remInt.p1 = 15<br />
Console.WriteLine(remInt.p1)<br />
In this case 15 is printed, just as one would expect, however to all other remoting clients and the process that has marshaled the remote object p1 does not change. It maintains the value that it held previously.
If anyone has experienced a similar problem and can provide me any assistance, I would greately appreciate it.
Thanks
|
|
|
|
|
Hi there
I am having problems using the XmlDocument class when editing an xml file.
This is what my xml file looks like :
<VTs_InfoKeeper>
<WebPwds>
<WebPwd>
<website>Code Project</website>
<uid>visiontec</uid>
<pwd>somefakepwd</pwd>
<description>gr8 website. c# fourms and more.</description>
</WebPwd>
</WebPwds>
</VTs_InfoKeeper>
This is the way i am using XmlDocument :
private bool SaveXml( string WebsiteName,
string UserId,
string Pwd,
string Description )
{
XmlDocument doc = new XmlDocument();
try
{
doc.Load("vtinfokeeper.xml");
}
catch(Exception)
{
return false;
}
XmlElement newWebPwd = doc.CreateElement("WebPwd");
XmlElement newWebsite = doc.CreateElement("website");
newWebsite.InnerText = WebsiteName;
newWebPwd.AppendChild(newWebsite);
XmlElement newUID = doc.CreateElement("uid");
newUID.InnerText = UserId;
newWebPwd.AppendChild(newUID);
XmlElement newPwd = doc.CreateElement("pwd");
newPwd.InnerText = Pwd;
newWebPwd.AppendChild(newPwd);
XmlElement newDescr = doc.CreateElement("description");
newDescr.InnerText = Description;
newWebPwd.AppendChild(newDescr);
doc.DocumentElement.AppendChild(newWebPwd);
XmlTextWriter tr = new XmlTextWriter("vtinfokeeper.xml",null);
tr.Formatting = Formatting.Indented;
try
{
doc.WriteContentTo(tr);
}
catch(Exception)
{
return false;
}
tr.Close();
return true;
}
Now when i run the above code i get this result :
<VTs_InfoKeeper>
<WebPwds>
<WebPwd>
<website>Code Project</website>
<uid>visiontec</uid>
<pwd>vtlives</pwd>
<description>gr8 website. c# fourms and more.</description>
</WebPwd>
</WebPwds>
<WebPwd>
<website>somwwebsite</website>
<uid>somewuid</uid>
<pwd>somwpwd</pwd>
<description>somedescr</description>
</WebPwd>
</VTs_InfoKeeper>
Whereas i wish to accomplish the result below :
<VTs_InfoKeeper>
<WebPwds>
<WebPwd>
<website>Code Project</website>
<uid>visiontec</uid>
<pwd>vtlives</pwd>
<description>gr8 website. c# fourms and more.</description>
</WebPwd>
<WebPwd>
<website>somwwebsite</website>
<uid>somewuid</uid>
<pwd>somwpwd</pwd>
<description>somedescr</description>
</WebPwd>
</WebPwds>
</VTs_InfoKeeper>
What am i doing wrong?
Can anyone plz point out the correct way that i should use
the XmlDocument class to get my desired result.
And as u can see that the pwd field is in clear text,
which way of encryption should i use to secure the pwds?
VisionTec
|
|
|
|
|
You loaded the document, then you told the document to create a new node. It doesn't know you want it inside the WebPwds element, so it just adds it to the end of its children (that means it adds it after the WebPwds element).
You need to call "AppendChild" or something similar from the XmlNode you want to add to. You could for instance do something like:
XmlNode webPwdsNode = doc.FirstChild;
webPwds.AppendChild(newPwdNode);
where newPwdNode is an XmlNode you created that contains all of the information you want.
I personally normally load in a document (I usually validate with a schema too when I load stuff in) and create classes based upon what I read (I do this by hand instead of using serialization). When it's time to write it out, I then create a XmlTextWriter and write out the document from scratch.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
<br />
using System;<br />
using System.Threading;<br />
<br />
namespace ConsoleApplication<br />
{<br />
class Page<br />
{<br />
private int _page;<br />
<br />
public Page()<br />
{<br />
_page = 0;<br />
}<br />
<br />
public int CurrentPage<br />
{<br />
get<br />
{<br />
lock(this)<br />
{<br />
_page++;<br />
return _page;<br />
}<br />
}<br />
}<br />
}<br />
<br />
class Class1<br />
{<br />
static bool stop = false;<br />
static Page page = new Page();<br />
<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
Thread[] threads = new Thread[5];<br />
<br />
for (int i = 0; i < threads.Length; i++)<br />
{<br />
threads[i] = new Thread(new ThreadStart(ThreadProc));<br />
threads[i].Name = Convert.ToString(i);<br />
threads[i].Start();<br />
}<br />
Console.ReadLine();<br />
}<br />
<br />
static void ThreadProc()<br />
{<br />
int i;<br />
while (!stop)<br />
{<br />
i = page.CurrentPage;<br />
Console.WriteLine("Thread {1}: Current page number: {0}", i, Thread.CurrentThread.Name);<br />
Console.WriteLine("Thread {1}: Downloading page {0}", i, Thread.CurrentThread.Name);<br />
Console.WriteLine("Thread {1}: Processing page {0}", i, Thread.CurrentThread.Name);<br />
if (i == 10) stop = true;<br />
}<br />
}<br />
}<br />
}<br />
Of course instead of the Console.WriteLine statements, there will actually be functions that perform the action.
What I'm worried about is the following: Since each thread is working with the same ThreadProc, isn't this at all going to affect the local variable (integer) i that refers to the page?
When I actually ran this code, I didn't get the statements to execute in order. Is that okay under the code circumstances? Again, what I mean is when one thread is executing, say downloading, it should then start processing the downloaded page. If that doesn't happen, and another thread, instead, starts downloading it's own page, wouldn't that affect the page processing of the first thread? I guess this is just another method of asking the same question: is anything going to happen to the local variable i in between thread calls?
Am I doing the right thing here, or should I use another method to do what I'm trying to do: Download 5 pages at a time. For each downloaded page: process it, and store information. When reaching 100 pages, stop.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
The thread proc is the method that's being executed in a separate thread, so no, the local variable i will NOT be affected. It's only when all the threads access a shared resource - like if you declared i as a field in the class that contains the thread proc. In this case, you can simply use the lock keyword against a shared object (typically in this case, you can lock against typeof(MyClass) so that only one thread can access that object at a time:
public class MyClass
{
private int i;
public MyClass()
{
for (int j=0; j<5; j++)
new Thread(new ThreadStart(this.Increment)).Start();
}
private void Increment()
{
lock(this)
i++;
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey,
I receive always following error :
{"Could not bind to the new value member.\r\nParameter name: value" }
System.ArgumentException
I don't find the problem in my source. Can someone have a look to it.
I use the property "Omschrijving" for the displaymember and that is not a problem. Why I have a problem with the property Id? I also check the whole array and there are no null-values in Id.
tkx,
Jac
My code :
..
this.Cmb01.DataSource = Codes.Splitsingen.Items;
this.Cmb01.DisplayMember = "Omschrijving";
this.Cmb01.ValueMember = "Id";
..
In an other class :
public class Splitsingen
{
public static Splitsing Jaarlijks = new Splitsing (1,"1",1,12,"Jaarlijks","Annuel","Yearly");
public static Splitsing Halfjaarlijks = new Splitsing (2,"2",2,6,"Halfjaarlijks","Semestriel","6months");
public static Splitsing[] Items = new Splitsing[5]{Jaarlijks,Halfjaarlijks,Trimestrieel,Maandelijks,Eenmalig};
}
public class Splitsing : CodeX
{
public int AantalPeriodesPerJaar;
public int AantalMaandenPerPeriode;
internal Splitsing(int id, string code, int aantalPeriodesPerJaar, int aantalMaandenPerPeriode, string omschrijvingN, string omschrijvingF, string omschrijvingE) : base(id, code, omschrijvingN, omschrijvingF, omschrijvingE)
{
AantalPeriodesPerJaar = aantalPeriodesPerJaar;
AantalMaandenPerPeriode = aantalMaandenPerPeriode;
}
public Splitsing()
{
}
}
public abstract class CodeX
{
public int Id;
private string OmschrijvingN;
public string Code;
public CodeX()
{
}
internal CodeX(int id, string code, string omschrijvingN)
{
Id = id;
Code = code;
OmschrijvingN = omschrijvingN;
}
public string Omschrijving
{
get
{
if (OmgevingParameter.Taal == Talen.Ned)
{
return OmschrijvingN;
}
}
set
{
}
}
}
|
|
|
|
|
Id in your code is not property - it's a field. Data-binding against properties on objects uses the PropertyManager , which binds against properties. Make Id a property and that should work for you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am writing a textbox validator control
how would I check to see if the person presses the backspace button and the delete button and then tell windows not to process those messages as I will do it all myself
------------------
I'm naked under my clothes...
|
|
|
|
|
Simple. Just handle the KeyDown event. Check the KeyCode that is passed to you on the KeyEventArgs for Keys.Delete or Keys.Back . If those are set, set Handled to true :
myTextBox.KeyDown += new KeyEventHandler(myTextbox_KeyDown);
private void myTextBox_KeyDown(object sender, KeyEventArgs e)
{
e.Handled = (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete);
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
is it possible to have a managed c++ class that inherits from an unmanaged c++ class? if so, how would i do that?
|
|
|
|
|
|
sorry. i meant c# class that inherits from unmanaged c++. is there a way to accomplish this?
|
|
|
|
|
No. You would have to encapsulate this unmanaged C++ class in a managed class. The easiest way would be to create a mixed mode Managed C++ assembly that encapsulates this in a managed class, then extend that from C#.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|