|
Hi Alisa..
When you done editing then use this method to close the popup window using following method.
lueCities.ClosePopup();
i am using this when i am adding some value and it automatically binding this lookupeditor
then it is also auto popup the contents..
hope it will help..
.....
Niranjan
|
|
|
|
|
hi,
i'm new to multithreading and i found it abit hard to understand. For example, i i were to have 3 thread which each prints the letter 'A','B' and 'C' respectively for 3 times(meaning, in total there should be 3 As,3 Bs and 3 Cs) and it is suppose to output as such ABCAABBCC. But how can i do it?
I thought of using Join method to ensure that the thread which writes A will execute the final 2 As and the same for Bs and Cs.....However, it does not seem to work... what should i take note of to ensure that it works accordingly?
Below are the codes that i've written wrongly i suppose.
using System;<br />
using System.Threading;<br />
<br />
namespace MultiThreading2<br />
{<br />
class Class1<br />
{<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
Thread t1=new Thread(new ThreadStart(WriteA));<br />
Thread t2=new Thread(new ThreadStart(WriteB));<br />
Thread t3=new Thread(new ThreadStart(WriteC));<br />
<br />
t1.Start();<br />
t2.Start();<br />
t3.Start();<br />
t1.Join();<br />
t2.Join();<br />
t3.Join();<br />
<br />
<br />
Console.ReadLine();<br />
}<br />
<br />
static void WriteA()<br />
{<br />
for(int i=0;i<3;i++)<br />
{Console.WriteLine("A");<br />
Thread.Sleep(2000);<br />
}<br />
<br />
<br />
}<br />
static void WriteB()<br />
{for(int j=0;j<3;j++)<br />
{<br />
Console.WriteLine("B");<br />
Thread.Sleep(2000);<br />
}<br />
<br />
<br />
}<br />
static void WriteC()<br />
{for(int k=0;k<3;k++)<br />
{<br />
Console.WriteLine("C");<br />
Thread.Sleep(2000);<br />
}<br />
<br />
}<br />
}<br />
}<br />
Thanks for any replies
|
|
|
|
|
Hi,
the fundamental idea of multithreading is to perform multiple tasks in a rather
asynchronous fashion, i.e. without predetermined order of execution; the goal is
to make optimal use of available resources e.g. performing calculations on data
as soon as such data is available.
If the subjobs must be executed in a very specific order, multithreading simply
makes no sense, since now the logic makes everything fully predictable.
Examples of unpredictable execution could include:
- some long winding calculations;
- some user interaction;
- a background printjob;
- a database query;
all of the above combined in one app.
It would not make much sense to orchestrate this in a fixed manner since
one never knows which subjob will take what time to execute, hence asyncrhonous
execution, using several threads.
In a typical application, there may well be a need to synchronize two or more
threads from time to time. Several mechanisms are available for this, typically
one thread waits for something (say a consumer needing some data), and another
thread signals something (say a producer providing some data). Known mechanisms
include: AutoResetEvent, ManualResetEvent, Queues, Semaphores, ...
Joining two threads is a drastic synchronization since now one of the threads
no longer runs.
I would suggest you:
- search and read some articles on multi-threading, here on CodeProject;
- experiment with a more appropriate example.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I encountered problem when trying to work with the Java
Plug-in. I compile my applet with J#, then add the component in my C# project. When I try to get the value of Java Vendor, I got Microsoft Corp, when I try to run the applet in purely HTML page, I got Sun Microsystems. I suppose it should use the Java plug-in to show
applets, but i think uses Microsoft JVM instead.
I have tried to solve this by setting a environment variable "JAVA_PLUGIN_WEBCONTROL_ENABLE" with value "TRUE", but still I got Microsoft Corp..
Please help...Thanks
|
|
|
|
|
Hi,
I don't know all the details, but normally a browser should let you choose which
virtual machine gets used. On IE6, look for menu Tools/Internet Options/Advanced,
then search both "Java (Sun)" and "Microsoft VM". These would list whatever
is available on your system.
I expect the WebBrowser class and the shdocvw.dll to use whatever is selected
in Internet Explorer. I don't know how other browsers present the choice, if any.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
1. I have some string that represent XML information - how can i using this string as XML ? what XML object to use ?
2. How can i get the relevant information from this XML ? what i mean is how can i know the XML attribute and data of this attribute ?
Thanks
|
|
|
|
|
1 - any one you like. XmlDocument is a good DOM implimentation to use.
2 - XPath
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i'm currently having a project that i need to work on using the webcam and sms services.
firstly,
We need to access to a webcam in c#,
then we have to show the video in a form from a web cam to the user's computer.
how do we come about doing that?
also,
i need to send and receive sms-es to and from the user's phone, through a GSM modem, communicating using C# too.
it needs to do basic functions like read, write, delete sms, send and receives smses.
is there a way to help me out?
by the way,
i'm a fresh newbie in C# programming.
please kindly help.
thanks a million!!
Fae
|
|
|
|
|
hello and thanks for reading this:
im having problems in getting the selected item(the text) from a combobox
when using the .datasource property.
i got something like this:
this.comboBox_add_to_group.DataSource = sku_ds.Tables[0];
this.comboBox_add_to_group.ValueMember = "SKU";
this.comboBox_add_to_group.DisplayMember = "SKU";
and im trying to make an event that any time the user changes the selected item within the combobox i would print to the console THE TEXT of the selected item.
but evrything i did return stuff like "system.data.....()"
so my question is is there a formal way to get the string that i see in the combobox when using the .datasource property , if so , how is it done?
thanks
Net
|
|
|
|
|
Hello...
Try this one.....
private void Form1_Load(object sender, EventArgs e)
{
DataSet ds = GetDataSet();
comboBox1.DataSource = ds.Tables[0];
comboBox1.ValueMember = ds.Tables[0].Columns["empName"].ToString();
comboBox1.DisplayMember = ds.Tables[0].Columns["empID"].ToString();
}
private DataSet GetDataSet()
{
SqlConnection conn = new SqlConnection(@"Data Source = PC6; Initial Catalog = Test; User Id = diipluser6; Password = willy007");
SqlCommand cmd = new SqlCommand("Select * From tblEmp", conn);
SqlDataAdapter adt = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adt.Fill(ds);
conn.Open();
conn.Close();
return ds;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
textBox1.Text = comboBox1.SelectedValue.ToString();
//MessageBox.Show(comboBox1.SelectedValue.ToString());
}
|
|
|
|
|
thanks for the reply ,
this line:
comboBox1.SelectedValue.ToString();
return this string for me:
System.Data.DataRowView
Net
|
|
|
|
|
If u Put all things as I shown then it wont show the problem......
Try it again is I shown....
|
|
|
|
|
The webpage pulls the ActiveDirectory UserName from the webpage itself and verifies it against a list in a SQL table to allow access. I am supposed to run a StoredProcedure which returns a boolean value for this purpose.
The application only contains FileUpload Control and a Button. No TextBox or anyother control should be used for UserInput. No UserInput is required for this application.
I never worked with Active Directory before. But I did some research today. But did not get anything substantial.
Your help will be appreciated.
|
|
|
|
|
If you want to interrogate Active Directory through the .NET framework then you can use either System.DirectoryServices or the System.Management namespaces. System.Management uses WMI to query AD. For either technique you need to supply a username and password to gain access to AD with and to perform queries.
You might need to store the username and password of a user who has enough previleages to access and update Active Directory in an encrypted format in some configuration file.
To give an example of using System.DirectoryServices here is a sample code which determines which users are part of the Domain Admins group.
DirectoryEntry de= new DirectoryEntry();
de.Path = "LDAP://clown.acme.com"; //clown is the server name hosting the domain controller & acme.com is the domain name.
de.Username = "administrator";
de.Password = "passw$rd";
de.AuthenticationType = AuthenticationTypes.Secure
//now lets search for a user using the above credentials
try
{
DirectorySearcher searcher = new DirectorySearcher();
searcher .SearchRoot = de;
searcher .Filter = "(cn=" + "Domin Admins" + ")";
SearchResultCollection results = searcher .FindAll();
Console.Writeline(results.Count.ToString())
}
catch (Exception exception)
{
Console.Writeline(exception.Message);
}
Further refer to this MSDN reference for more information:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/quick_list_for_c__code_examples.asp[^]
Just a warning Active Directory can be a pain at times.
|
|
|
|
|
Hello everyone,
I am trying to pass an instance of a serial port to an instance of a class declared in the same scope. When I pass the port in, either by reference or value, I keep getting a null reference exception. The serial port works fine when used outside of the target object, but I can't get it to work from within that object.
Here is what I mean...
private System.IO.Ports.SerialPort serialPort1; //the serial port declared within Form1
private InterfaceCommuncation Communicator; //the object that needs to use the port
//port initialization stuff (abridged)
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 38400;
this.serialPort1.Open(); //this line works fine, no errors
this.serialPort1.Close(); //this line works fine, no errors
//both of these lines cause the same error
//Communicator.initialize(serialPort1);
//Communicator.initialize(this.serialPort1);
******
//This is how the serial port is used in the communicator class
public void initialize(System.IO.Ports.SerialPort sp)
{
sp.Open();
sp.Close();
}
The null reference error occurs inside this function, wether I pass by reference or value. What is the proper way to pass a serial port to another object?
Thanks in advance!
|
|
|
|
|
Hi,
SerialPort is a class, hence a reference type.
You can declare SerialPort references as much as you like, and copy them,
and pass them from one object to another; but you can only create SerialPort
instances (i.e. real objects) by using the "new" keyword.
"new" is not present in the code you have shown, if it is not there at all
then anything you try to do to serialPort1 is doomed to fail with a
NullReferenceException.
Also relevant could be the following MSDN remark on SerialPort.Open:
"The best practice for any application is to wait for some amount of time after
calling the Close method before attempting to call the Open method, as the port
may not be closed instantly."
Since they don't specify "some amount of time" this is not very practical;
the better approach may be to open the port only once.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc,
Thank you for the reply. I have tried using new in the following way, with the same error...
1. making a new instance, and passing it by reference
2. making a new instance, and passing it by value
3. making a new instance, and passing it by both ways to another new instance inside of the target class
Any more suggestions? I greatly appreciate your help.
I also noted the MSDN remark and changed the open/close stuff.
Regards,
Chris
|
|
|
|
|
murr007 wrote: Any more suggestions?
Sure, these two: stop wild experiments and:
1. show the code for one of them, preferably the one you consider the most likely
2. buy a book on C# and work your way through it; books tend to teach you stuff
in a logical order, with simple examples.
BTW if you show code, put it inside PRE tags so we can enjoy the indentation.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi all,
I have a small problem with keyboard input. I have a textbox and I would like to prohibit writing characters(only numbers are allowed).
Do you have any ideas?
Thanks.
David
|
|
|
|
|
Add a Keypress event handler to the textbox, and do this:
if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
} This assumes that the event args is called e.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
It works!!!
e.Handled = true; what that means?
Thank you.
David
|
|
|
|
|
It tells the textbox that the key was handled (was taken care of) and no need for the textbox to handled it
|
|
|
|
|
Perfect!!
Thank you very much.
David
|
|
|
|
|
I've been writing a chat client, which uses an extended RichTextBox as the chat area.
The RichTextBox takes simple XHTML code (including styles) and converts it into Rtf and displays it. This works great for almost everything.
The problem arises when you try to use extended UTF-8 characters, most notably Japanese Hiragana and Katakana, but also things such as the musical Sharp symbol or the interrobang symbol. These are being displayed as question marks in the RichTextBox.
They exist without problems in the input XHTML; and using a standard RichTextBox I am able to display them correctly. The problem arises when I insert them via the translated XHTML.
Does anyone know of a way that I can preserve the characters when converting to Rtf?
|
|
|
|
|
Hey all I have developed an application that makes use of the upnp.dll, but for some reason my application works fine on some computers but there are a select few that it doesn't work on and I get this error message:
System.Runtime.InteropServices.COMException (0x80070422): Creating an instance of the COM component with CLSID {E2085F28-FEB7-404A-B8E7-E659BDEAAA02} from the IClassFactory failed due to the following error: 80070422.
at [ApplicationName].ServerDetection.StartAsyncTypeSearch()
Can anyone shed some light on what is happening I can't seem to pin this error down.
Any help on this will be highly valued.
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|