|
Hello,
Is it a question of multi selection?
In this case you should make your code dynamic and hold the references of your TextBoxes in a Hashtable.
private Hashtable AllTextBoxes = new Hashtable();
AllTextBoxes.Add(0, textBox1);
AllTextBoxes.Add(1, textBox2);
}
private void button2_Click(object sender, System.EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Multiline = true;
if (dlg.ShowDialog() == DialogResult.OK)
{
for(int x=0;x<AllTextBoxes.Count;x++)
{
TextBox actTB = AllTextBoxes[x] as TextBox;
if(x<dlg.FileNames.Length)
{
actTB.Text = dlg.FileNames[x];
}
else
{
actTB.Text = "";
}
}
}
}
If I didn't understand you right, please let me know.
All the best,
Martin
-- modified at 5:39 Thursday 1st February, 2007
|
|
|
|
|
I have windows application
when i log out from the application and login again
all values are pre filled in textboxes ans list boxes
i want that they get cleared when i logout
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
do i have to reset all the textboxes or is there also some other way to do it
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
I am doing like
txtbox1.clear();
textbox2.clear();
can i do it in one go with a single function for whole form
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
You can iterate over the controls collection and when you find textboxes or listboxes, clear them.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
can u give me sample code how will i do that
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Hello,
Just use a foreach over your Controls Collection.
foreach(Control c in this.Controls)
{
Label actlabel = c as Label;
if(actlabel != null)
{
actlabel.Clear();
}
else
{
ListBox actlistbox = c as ListBox;
if(actlistbox != null)
actlistbox.Items.Clear();
}
}
All the best,
Martin
|
|
|
|
|
Hello,
I am getting a C# compiler warning for using Thread.Suspend() and Thread.Resume() methods:
Warning 6 'System.Threading.Thread.Suspend()' is obsolete:
'Thread.Suspend has been deprecated. Please use other classes in System.Threading,
such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect
resources. http://go.microsoft.com/fwlink/?linkid=14202'
I'm implementing these thread methods in a safe environment, when only a single worker thread accesses the resources. This worker thread is performing a lenghty calculation so I wanted to have an option to suspend/resume this CPU intensive and lenghty calculation.
Is there any other simple way to accomplish this task? Monitor, Mutex, Event nor Semaphore don't seem to be an effective replacement for Suspend() and Resume().
Thanks much,
Michal Kreslik
|
|
|
|
|
Thread.Sleep(Timeout.Infinite) should halt the thread. you can then interrupt it if you want it to start doing things again.
HTH
Russ
|
|
|
|
|
OK, thanks, but Sleep() is a static method, so it's not possible to call this method on any thread other than the current one, correct?
That means that it's not possible to put a thread to sleep externally this way. Is that true or am I missing something?
Thank you,
Michal Kreslik
|
|
|
|
|
i think the aim of the changes to the resume and suspend methods was that code that executes outside a thread doesn't know what resources the thread is using.
If for instance there was a database transaction open in the thread that you are putting to sleep you could create chaos for all users of the application not just the specific instance that the thread is running in.
I think the general plan is to check for the state of a variable somewhere in your code
while(_running)<br />
{DoStuff();}<br />
else<br />
{<br />
ReleaseExpensiveResources();<br />
Thread.Sleep(Timeout.Infinite);<br />
}
This way the thread won't suspend immedeately but it will suspend cleanly when it releases.
Russ
|
|
|
|
|
Hi
I m developing a web portal in c# asp.net web application .i want to built an email client.My email client will include the functionalty as
Making new account
sending e mail with attachments
receiving email with inbox maintaing facility. etc
but i have not any idea about it. Can any one guide us first of all about the email server that which server should b used 2ndly how it can be used n from where v can get help regading its builtin methods to b used in email client.
v want help in C# not in HTML codin
Thanx
|
|
|
|
|
Hi
I m developing a web portal in c# asp.net web application .i want to built an email client.My email client will include the functionalty as
Making new account
sending e mail with attachments
receiving email with inbox maintaing facility. etc
but i have not any idea about it. Can any one guide us first of all about the email server that which server should b used 2ndly how it can be used n from where v can get help regarding its builtin methods to b used in email client.
v want help in C# not in HTML coding
Thanx
Fakhraz
|
|
|
|
|
Get IIS Installed... install the SMTP Server... which comes with the windows cd... follow the instructions... make sure your server runs on 24/7 basis and it's a very good server.
get a free javascript text editor from the internet or better build one yourself.
use the Mail Class in C# for sending mails in attachment... research the internet...you can also use ajax for better user experience just like gmail does.
it won't take more than 2 months...
best of luck... and if you make it then please send me your url... i also would like to open a free email account....!
Regards,
Mahernoz
|
|
|
|
|
I have done that all but even after the configration settings which i m sure that i have done correctly i get the exception of CDO....... sort some thing
|
|
|
|
|
Hi,
I am facing some problem with the threads in my application. I changed the threading attribute from MTAThread to STAThread due to some reason and because of that I am facing an contextswitch deadlock exception after approx every 4 mins.
The Exception:
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x159bc0 to COM context 0x1598e0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
In few of the forums, people have said that there is no harm in disabling this exception in the following way -- "Simply uncheck the ContextSwitchDeadlock exception under Debug.Exceptions.Managed Debugging Assistants if you just want to ignore the exception in the debugger".
I want to know if there will be any performance issues or memory leakage of any sort. Will this affect my over all application in any way.
Please help me on this.
Thanks
KR
|
|
|
|
|
What i would do is compile the code as "Release" and run this from outside the Visual Studio Dev environment. If the problem is not present then you may simply ignore the exception.
|
|
|
|
|
My code is,
AxMSChart20Lib.AxMSChart chart = new AxMSChart20Lib.AxMSChart();
chart.Title.Text = "My first chart";
this.Controls.Add(chart);
When i use this code, i get this exception,
"InvalidActiveXSateException was unhandled"
Exception of type:
'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.
Can u tell, how can this be corrected?
Thanks-Guna
|
|
|
|
|
To get rid off that exception, Just add the control first with your container before using any of it's properties or methods.
AxMSChart20Lib.AxMSChart m_objChart = new AxMSChart20Lib.AxMSChart();
this.Controls.Add(m_objChart);
m_objChart.Title.Text = "My first chart";
|
|
|
|
|
iam workin in c#2005(desktop applications) i used datagird and i want to merge some columns together to appear as parent header to theses columns like the property (merge)we use it in excel to merge cells from columns to appear as one cell
ma_refay
-- modified at 3:24 Thursday 1st February, 2007
|
|
|
|
|
You'd have to define a template for your grid so these 'columns' are one column to begin with.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi everyone!
How to get Office 2003 color?
Office 2003 Color not like Xp Color.
I just get color.
Thank You.
Sorry for bad English
|
|
|
|
|
You'd need to download a UI library to make your app look like Office 2003.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I am writing a project here in Australia that hopefully will be used in many other cultures.
I am having troubles coming to grips with how to handle different cultures particularly as it relates to database date/time formats and the various controls that rely on culture information.
Specifically, the database that the project revolves around is MS Access. Concentrating on just one field I have created - the DOB and is obviously a date/time field. The dates in the db are in English - Australian format ie dd/mm/yyyy.
I want to be able to enter the DOB into this field and would like to use a maskedtextbox to do this. Unfortunately, the provided mask (.Net v2) for date doesn't work whether I specify that controls English - US OR the English - Australia cultures. Essentially, if the first field (either whether it's month or day depending on the culture selected in the Control setting) has a 0 as it's first number, the date is not displayed correctly nor is it recorded in the DB correctly.
I have managed to avoid this issue up till now by formatting the user input into mm/dd/yyyy format for input into the database however this is not an apparent option with the maskedtextbox.
Can someone point me to a good tutorial on culture in the .Net framework and especially to VS2005 or perhaps at least guide me in the right direction? I would rather a hands-on tutorial rather than the heaps of theory and high level discussion type web sites. I need practical help
Is it preferable to ignore the local culture and force programatically all data (including the MS Access database) to be in a specific culture. If so - how?
Thanks in advance.
Glen Harvy
|
|
|
|
|
If you're using a datetime format in the database, and the DateTime object in your code, then the only issue is how you render the details in your UI layer. You can check in your UI layer for the correct way to render the display/input controls. Or, just use a calendar control, that's always the same, and show dates as 12 Jun 2006, for example.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|