|
The RichTextBox control does not support HTML formatting. In order to display the formatted text, you need to convert the HTML to RTF, then set the RichTextBox.Rtf property to the converted text. The slick way to do it would be to create your own ICustomFormatter object that converts HTML markup to RTF, then pass it, along with your HTML string to StringBuilder.AppendFormat.
I don't know of any other way to tackle this problem. I'm sure there is a myriad of conversion tools out there and quite possibly an article or two on that topic on CP.
Sorry I don't have a better solution. Perhaps someone else does?
Ian
|
|
|
|
|
|
for example:
public class Foo<T>
{
T total=default(T);
void Add(T val)
{
total+=val;
}
}
which results in the compiler error:
"Operator '+=' cannot be applied to operands of type 'T' and 'T'"
Is there some way to tell the compiler that T is a value type? I don't see it in the possible constraints for T.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Use the where keyword:
public class Foo<T> : where T : struct {
T total = default(T);
void Add(T value) {
total += value;
}
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: Use the where keyword:
I tried "where T: struct" and I get the same error message.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
You have to add contraints. Right now, the only thing the compiler knows about the type T is that its an object. I don't believe though you'll be able to do something like that because there's no interface for 'numeric' or something ;-D.
If you find something that works...please let me know. I've had to write something like this where I broke it out to a case by case basis.
|
|
|
|
|
Andrew Rissing wrote: If you find something that works...please let me know.
See Incincere Dave's post in this thread. A couple really cool articles on CP that address the problem.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
|
Insincere Dave wrote: Here are two methods
Ah, I remember that article on using generics for calculations. In fact, I had voted a 5 for it!
Thank you so much for bringing those two links to my attention.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hi All:
I am trying to work with the built in double buffering in C# Visual Studio 2005. I want to have no flicker. I have a timer event that throws an event every 100 ms when the timer event occurs it draws a square at the given location. This occurs very quickly. Behind the square is a four quadrant background. I am trying to do the double buffering so that the background is not redrawn everytime or so that it is smoother. When I set the doublebuffer function to true it flickers faster so I am obviously not doing something right. Please help!
Please view my Paint function:
<br />
public void XYZ_PaintData(object sender, PaintEventArgs e)<br />
{<br />
Graphics g = e.Graphics;<br />
Pen penRed = new Pen(Color.Red, 2);<br />
Pen penGreen = new Pen(Color.Green, 2);<br />
Pen penBlue = new Pen(Color.Blue, 2);<br />
Pen penWhite = new Pen(Color.White, 1);<br />
Pen penBack = new Pen(Color.Gray, 1);<br />
<br />
this.DoubleBuffered = true;<br />
<br />
<br />
<br />
penBack.DashStyle = DashStyle.Solid;<br />
<br />
g.DrawLine(penBack, 375, 105, 375, 600);<br />
g.DrawLine(penBack, 50, 325, 650, 325);<br />
g.DrawRectangle(penBack, x0XYZ, y0XYZ, x1XYZ, y1XYZ);<br />
AccelReadings = true;<br />
<br />
g.DrawRectangle(Pens.Black, xMXYZ, yMXYZ, 2, 2);<br />
<br />
<br />
}<br />
Laura
|
|
|
|
|
Well, I don't know what's causing the flickering, but I do see a HUGE resource leak in your code.
You MUST call .Dispose() on all of your Pen objects when you're done using them. If you don't, the unmanaged resources behind them don't get released and you'll eventually get an OutOfMemory exception and/or your system will start to do very weird things, even causing other applications to crash.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I would set DoubleBuffered only once, probably in the constructor.
Maybe setting it every time causes the flickering you see.
And you either should make your pens class members (so they get created only once),
or Dispose of them every time you create them (wasting CPU cycles in creation, disposal
and garbage collection).
I am not sure what "AccelReadings=true" is supposed to do there. Seems not to belong
in a paint handler.
Final remark: the comment "Line that is drawn when timer event occurs" is inaccurate,
the line is drawn every time paint is executed (which could be on every time tick and
more), it probably gets instructed to move in the time tick handler.
Hope this helps.
|
|
|
|
|
Laura,
Another thing you can try is your own simple double buffering: Paint everything to a temporary bitmap and then paint the bitmap to the graphics passed by the event args, like so:
Bitmap temp = new Bitmap(e.ClipRectangle);
// do your painting
e.Graphics.DrawImageUnscaled(temp, e.ClipRectangle);
That may help.
Incidentally, are you using transparency of any kind? Transparency can cause flickering despite double buffering.
|
|
|
|
|
we are creating Online Exams Module.Just lke any other online exams on other real sites.
The Case is the user can attempt any question within 3 minutes.after 3 minutes,the next question automatically disappears and another question comes on the page.
We also want to show times in Minutes as a clock just like any other online exams.
My issue is that how can i show time on each page and how can i calculate every 3 minutes.
I know there is Timer/Thread class in c# for web application.But i dont know how they can efiicently work.
Or there is any other better method to do it.
Plaese help me with example or code.
---
My code is like this:-
System.Timers.Timer time1=new Timer();
time1.AutoReset=true;
time1.Interval=60000;
time1.Elapsed+=new ElapsedEventHandler(time1_Elapsed);
And..
private void time1_Elapsed(object source,System.Timers.ElapsedEventArgs e)
{
//call any function
}
but my WebForm seems running ambigously to me and not giving proper result.
Am i in right direction.
Please help me with suitable simple.
MY PLATFORM IS ASP.NET 2005
Posted via DotNetSlackers.com
|
|
|
|
|
Hold the timer object in session variable
It' will be work.
Parwej Back...............DON of Developer.......
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
|
Jeez - You get impatient after only half an hour. Perhaps, if you need the information this fast, you might want to pay for a support call to Microsoft. Here you will get help by volunteers who help out when they can, not at your whim.
|
|
|
|
|
You've been here for over two years, so you should know how a forum environment works by now. Making a demand like this after waiting only 30 minutes is just ludicrous.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am working on one app
Ihave one gridview where i write information but when i restart my app the informations are gone!!??
Help me !!!!
Please!!!!
Thanks
nemanja
|
|
|
|
|
You will need to persist the data somehow.
That is, when a new row is added you need to find some method to take the data contained within that row, and store it somewhere. That could be a database, xml file, plain text file or something else - it's up to you, you're the developer. It's not excel.
|
|
|
|
|
I have a class assembly that references the IMB WebSphere MQ system. I have to register the MQ one time before I can start making calls. I would like to do this when I load my class assembly. What's the best way to achieve this?
Tanks
Phil
|
|
|
|
|
You can do this in the class constructor (or a static constructor) as long as you put the appropriate safegaurds in place.
You want to make sure that once MQ has been registered you don't try to do it again. You also want to make sure that if the registration fails, your constructor doesn't throw an exception but sets the class state in such a way that the class is created but not usable. Throwing an exception in the constructor will result in a very ambiguous "Type initialization failed" error message.
The better way would be to create a singleton class that manages the relationship with MQ. The singleton is instantiated once in your class constructor. It would need to provide an explicit "register" method, and any other methods that access MQ would be part of this singleton and can take advantage of the register method implicitly. The benefit here is that everytime you make a call to MQ, the system verifies that MQ has been registered, and if not registers it before making the call.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I had thought about that approach. I'm trying to eliminate the need for the user of my library to initialize the library (hiding the details). It's almost like the global.asax file - with the Application.Start event. If there was an Assembly.Load event or something similar that i could hook into, so the initialization could be done automatically.
Phil
|
|
|
|
|
There aren't any equivalent events like Assembly.Load. It still sounds like the best approach would be to implement a singleton MQManager class. Since it is a singleton you can hide all of the initialization details behind an explicit Register method. Each "normal" method can check the state and initialize as needed.
Something like this (rough pseudo-code):
public class MQManager {
private bool registered;
public void Register() {
if (!registered) {
registered = true;
}
}
public void AddMessage() {
Register();
MQ.Add();
}
}
Since the Register function protects itself from registering more than once through the registered flag, it is safe to call multiple times. Also, since the AddMessage function makes a call to Register before doing anything else, it is safe to be called by the user without having first explicitly called Register .
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I appreciate the help.
If that's what I got do - then that's the way I'll go.
Tanks
Phil
|
|
|
|