|
There's an MS Word COM control you could use. It requires that Word be installed on the users machine, and IIRC it's version specific so you'd need to build a separate app for each version of word your clients use. Also it only provides a limited subset of the toolbar and menu options with AFAIK no way to change them. You can find more information via google.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
thank you all of you.lockepeak
|
|
|
|
|
im woking with web forms....I would like to change the backround of web form at run time....how can I achieve that?...
Hi,Im Razana
|
|
|
|
|
Hi, I'm Malcolm
I thought this was gonig to be easy to answer...but unless somebody wants to make me look stupid, it isn't that straight forward. Try this...
Change your <body> tag
<body id="bodytag" bgColor= "#000099" runat="server">
and then in the event handler that is called to change the colour (or on PageLoad) call :
bodytag.Attributes.Add("bgcolor", "#EE33AA");
obviously setting which ever colour you want.
Is there a better / different way anybody? I never change the background color!
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
|
Hi all,
I am writing an application in which i have a loop to write some outputs over the text box .After i run the application, it works fine as long as i stick to the form and do not click anywhere. As soon as i open any other window to work on and then go back to that output form..It freezes the application and doesnt respond.
The code for instance is as shown below...
<br />
while (true)<br />
{<br />
if(count > 1000)<br />
{<br />
break;<br />
}<br />
<br />
Thread.Sleep(1000)<br />
TextBoxA.Text += "Message" + Environment.NewLine;<br />
TextBoxA.Refresh();<br />
count++;<br />
<br />
}
I guess its something to do with threading...But i am not too sure about it. Pls point me the right direction....
Thanks
SS
|
|
|
|
|
For windows forms in .net 2.0 you can use the BackgroundWorker[^] control. You place it on the form and then put your code into the Do Work event.
If you need to do this in .Net 1.1 or outside of win forms then you can use the Thread Class[^] directly.
To do this you make a new method which takes no parameters and has no return value:
private void TestThread()
{
//DO STUFF
}
Then you create a new thread and start it:
System.Threading.Thread testThread = new System.Threading.Thread(new System.Threading.ThreadStart(this.TestThread));
testThread.Start();
You can also pass things to the thread but I'll leave that for you to read up on
One last thing to note, if you are working with windows forms then you'll need to use the Invoke method on any controls you access across threads.
http://www.codeproject.com/csharp/threadsafeforms.asp[^]
|
|
|
|
|
hey thanks for your reply...
I have added this backgroundWorker and copied the code to backgroundWorker1_DoWork event. Now how can i call this backgroundWorker1_DoWork under btn pressed event to execute the loop...??
Thanks
|
|
|
|
|
Generally, it works like this:
System.ComponentModel.BackgroundWorker bw = new System.ComponentModel.BackgroundWorker();
bw.DoWork +=new System.ComponentModel.DoWorkEventHandler(bw_DoWork);
bw.RunWorkerAsync();
But why not look at the MSDN example?
Standards are great! Everybody should have one!
|
|
|
|
|
Dont know ..its bit confusing at the moment. Well i am getting exception Cross-threaded operation not valid..
I am trying to achieve simple operation that is execution of the code i mentioned in my first post.
I just have one textbox and a button over the form. Now i added backgroundWorker component over the form. Double clicked over DoWork event.
Now i have a startbtn click and DoWork event. So do i need ProgressChanged or RunWorkerCompleted event or no..??
If not then do i have to just paste the first post code under DoWork event and add some extra code under start button event to execute the loop or is there any different approach. If its true then what would be that extra code that i have to add under start button event so that it performs what i am trying to...
I dont think it works with
backgroundWorker1.RunWorkerAsync(); .........?
Well in MSDN they have given some differnt example and i am doing something really simple...
Thanks
|
|
|
|
|
So do i need ProgressChanged or RunWorkerCompleted event or no..??
Yes. You're getting the Crossthreading exceptions because you're trying to do an operation on a thread other than the thread the UI control was created on. This isn't allowed in forms. You can use ProgressChanged and RunWorkerCompleted to avoid this. Use the ReportProgress together with the ProgressChanged event to achieve this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
BackgroundWorker bw = new BackgroundWorker();
public Form1()
{
InitializeComponent();
bw.WorkerReportsProgress = true;
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
bw.RunWorkerAsync();
}
void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
this.Text = "Looped " + e.ProgressPercentage + " times";
}
void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Close();
}
void bw_DoWork(object sender, DoWorkEventArgs e)
{
int i = 0;
while (i++ < 100)
{
bw.ReportProgress(i);
Thread.Sleep(100);
}
}
}
}
Standards are great! Everybody should have one!
|
|
|
|
|
cross-threaded operation etc. is caused by controls being updated by any thread other than the one that created them. The background worker control should stop this. Otherwise you need to call begininvoke on the control that you are updating. There are loads of examples of this on CP and MSDN.
Russ
|
|
|
|
|
I do my homework. and I met this.
there are 3 forms in the project. in the 3 one is the main form 2 is the sub. and in the sub form I want to use some variable in the main form. for example in the main for have a connection object variable when the main form loaded the connection object created. and I open another one sub form and I also want to use the main form's connection object. and I do know how to do it.(all this I do it in C#)
Please give me some idea!
thanks!
|
|
|
|
|
Hi - search the forums. This question must be posted at least once a week.
Try clicking here...[^]
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
See this article on passing values between forms (or any related classes for that matter): http://www.codeproject.com/dotnet/passingvaluesbetweenforms.asp[^]
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Has someone already create a TreeView control (or a listview with tile style) with the possibility to insert an element (node or row) with double row? (like the windows xp's explorer on certain type of file)
I explain better
open explorer, go in a folder with some MP3s, set the view in Tile (title) mode: All files are rapresented with more than one row (filename in the first; artist in the second and album in the third)...
i have to do a listview like this!!
|
|
|
|
|
hi..
don't you mean multiple columns?
if so, you can set the View - Property of you Listview to System.Windows.Forms.View.Details
greets
M@u
|
|
|
|
|
nono.. 2 rows!
see example:
http://aycu12.webshots.com/image/21971/2000690791167390529_th.jpg
|
|
|
|
|
Hi all
I am new to MSMQ.I have an application which sends a message.This message will be recieved by another application and stores in a MSMQ.And then it will read from the msmq and sends to some other process.Now the thing i am facing is that i have a recieve thread which starts at the application_start event .inside this thread i am calling the receive method of msmq.and i am using the follwing code with timespan
msg = mq.Receive(new TimeSpan(0,0,100));
now i know after 100 ms it will show MessageQueueException.my doubt is that what should i do after i catch the exception,because i want the thread to abort only at the application_end.so what should i do if a exception occurs.
Thanks in advance.
Regards
DilipRam
|
|
|
|
|
ramdil wrote: what should i do if a exception
What do you want your app to do? wait for another message? do nothing until the app exits?
|
|
|
|
|
Yes it should wait for message to arrive.
actually since i have started my thread on application , then the recieve method will get time out after the span of time ,it will throw messaging exception..so my doubt is in this exception section, i again need to wait until message comes
Regards
DilipRam
|
|
|
|
|
so catch the exception inside of a while loop:
while (listenForMessages)
{
try
{
msg = mq.Receive(new TimeSpan(0,0,100));
listenForMessages = false;
}
catch (MessageQueueException ex)
{
}
}
|
|
|
|
|
Thanks for the reply. i dont want to catch the exception.i want it to listen again..so what should i do..if i move a thread to sleep(100) in exception, will it serve my purpose. i am pasting my code section.
while (IsMessageRecieved)
{
try
{
mq = new MessageQueue(XMLMSMQRecievePath);
msg = mq.Receive(new TimeSpan(0,0,100));
XMLMSMQFileName = msg.Body.ToString();
}
catch (System.Messaging.MessageQueueException ex)
{
Logging.TraceError(ex.Message);
mq.Purge();
Thread.Sleep(100);
}
Regards
DilipRam
|
|
|
|
|
I'm not quite sure that I fully understand you. If you don't catch the exception then the program will explode. From the code segment posted, it looks like you want to read the first available message from the MSMQ and store the body of it in the variable "XMLMSMQFileName" and for each 100 ms that no message is received log an error . . . is this correct?
If so there are a few things to note:
1) there's no need to set mq to a new MessageQueue in each iteration of the loop. setting it once before the loop should be sufficient
2) if the timeout expires and the exception is thrown that means there are no messages in the queue, so calling Purge() is unnecessary
3) IsMessageRecieved needs to be set to true or else it will keep reading messages from the queue
|
|
|
|
|
Thanks for the reply.yes..it will wait for 100ms then not will go to exception.but i dont want to set the flag value to change,because what i want is that if the error occurs, then it should again wait unitl message comes..
so i am asking that if i am adding thread.sleep(100) will serve my purpose
..that means what actually i want is that on exception i dont want to exit the loop but should wait for the mssage to arrive..
will my code will satisfy if do sleep(100).hope i am clear with my requirement
Thanks in advance
Regards
DilipRam
|
|
|
|