|
I've been searching around for an easy way of saving a formatted RTF box as an html file. I found a DLL that costs 250 bucks... but I'm sure there's an easier (cheaper) solution out there...
anyone got any advice?
|
|
|
|
|
I don't know any good solution, but I wrote a (very simple) RTF to HTML converter a while back. It doesn't support images or table or anything like that, only plain formatting.
|
|
|
|
|
what about colors and fonts and everything?
|
|
|
|
|
There are several RTF-to-HTML converters on the web if you're willing to spend a few hundred dollars.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
I am creating an ASP.Net web application using C#. In one of my page, I need to load a list of a thousand names to be display in a DataGrid table. The table has 3 columns, a first name column, last name column, and a third column containing a delete link. The table can be sorted by first name or last name. When EnableViewState is set to true, it takes up to 1 minute to load the info into the DataGrid and display the table. When I set EnableViewState to false, it takes about 15 seconds to load the table, but I cannot sort the table anymore. I have set breakpoint in my sort command code, but it never gets hit when I click the first or last name link to sort the table. Setting a breakpoint in the IniatializeComponent show that the sort event was triggered, but my sort code is never called. I have no idea what's going on and would appreciate any help.
|
|
|
|
|
Please don't double post.
---
b { font-weight: normal; }
|
|
|
|
|
How do you access jpgs bitmaps and icons in a resource file?
|
|
|
|
|
I have a previous post here[^] that might help.
Enjoy.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thank you very much for your help.
I have tried your code, it compiles but I get the error "Stream is not a valid resource file"
I created a MyResources.RES file using RC.exe and compiled the app with the following command line :
csc /debug- /t:winexe /win32res:MyResources.RES /w:4 /o+ *.cs
It seems to embed the resources in the exe as it much larger than if i do not have the /win3res switch
any idea why it won't work?
|
|
|
|
|
Assuming you're not creating the resource you're consuming (if you were, I would suggest saving a lot of hassle and just using the ResourceWriter type), and you're stuck with a Win32 resource, you should be able to use the ResourceManager type to get what you need if, as your example suggests, you're embedding the resource in your application assembly.
Example (where the byte array is your serialized image stream):
public byte[] Binary(string key)
{
ResourceManager resManager = new ResourceManager("[ASSEMBLYNAME]", This.GetType().Assembly);
return (byte[]) resManager.GetObject(key);
}
Here[^] is a link with a little more info.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Using win32 resources looks very complicated (looked your url)
Maybe I am going about it all the wrong way.
What is the best way to use icons and jpgs/bmps in a c# application?
Would I need to have seperate files to keep with the exe or can they be embedded into the exe?
At the moment I have 6 BMPs that I use in an image list for use on a listview, and at the moment I have the exe and the 6 BMP files in the same folder so i can access them.
I also would like to add an icon the exe and the status bar and stop using the default one.
Would I need to have seperate file(s) to the exe to allow this?
Thanks again for your help
|
|
|
|
|
Using Win32 resources is not particularly complicated in general, but the .Net Framework does not have stellar legacy support built in.
See the link in my initial post, using ResourceWriter and ResourceReader. It should do exactly what you're suggesting, and provides examples for how to read from and write to .resources files.
You can put more than one resource in a .resources file; they are added in key/value pairs.
Good luck.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
OK thanks for all your help
I will try getting this working using your original post
|
|
|
|
|
I have two TextBoxes. I have a button that calls a method that will use the
input from the text boxes ONLY if a number is entered. How do I do I do this?
Tried for several nights-- but I keep crashing on non-numerical input...
--thanks in advance
|
|
|
|
|
Void OnButtonClick(...)
{
Try
{
int i = Convert.ToInt(textbox.Text);
}
catch
{
return
}
DoSomething();
}
|
|
|
|
|
Dan- thanks. I have already tried the code you've shown. My problem is that BOTH text boxes are "tied" to the button event-- so I keep getting an infnite loop of two MessageBoxes (each from the catch statements of the two TextBoxes)
when there is an invalid entry....
|
|
|
|
|
I'm not sure I follow you here. Are you doing your check event when the button is clicked, or when a user modifies the content of eitehr box?
|
|
|
|
|
Ok Here's what I did...program crashes on invalid input and I get endless Message boxes that won't close on 'OK'. Thanks...
This is driving me nuts....
///////////////////////////////
void DrawComplexNumber1(Graphics g)
{
Pen p = c_xy.GetNextPen();
p.DashStyle = DashStyle.Dot;
c_xy.SetOrigin(xIndent + graphRect.Width/2, yIndent + graphRect.Y/2);
try
{
cmplxValue1.Real = Convert.ToDouble(textComplex_1Real.Text);
}
catch
{
MessageBox.Show("Error!");
}
try
{
cmplxValue1.Imaginary = Convert.ToDouble(textComplex_1Imaginary.Text);
}
catch
{
MessageBox.Show("Error!");
}
g.DrawLine(p, 250, 250, (float)(250 + (xIndent * cmplxValue1.Real)), (float)(250 - (yIndent * cmplxValue1.Imaginary)));
//////////////////////////////////////////////
private void complex_1OK_Click_1(object sender, System.EventArgs e)
{
drawLine1 = !drawLine1;
Invalidate();
}
/////////////////////////////////////////Paint Handler
....
if(drawLine1)
DrawComplexNumber1(e.Graphics);
}
|
|
|
|
|
hi
How about using int32.parse(textbox.text) ?
Banshi Khinchi
|
|
|
|
|
You see the following code :
private void button1_Click(object sender, System.EventArgs e)
{
int number = 0;
try
{
number = System.Convert.ToInt32(textBox1.Text);
}
catch(Exception ex)
{
System.Windows.Forms.MessageBox.Show("Input is not a number !");
textBox1.Focus();
return;
}
DoSomething(number);
}
private void DoSomething(int iNumber)
{
// Your code is here ...
}
with textBox1, textBox2 are two instances of TextBox class and button1 is a instance of Button class.
NPS.
|
|
|
|
|
Handle the Validating event for both text boxes:
private void TextBox_Validating(object sender, CancelEventArgs e)
{
TextBox textBox = sender as TextBox;
if(textBox == null)
return;
if(textBox.TextLength == 0)
return;
bool error = false;
try
{
int n = Convert.ToInt32(textBox);
if(n < 0 || n > 100)
error = true;
}
catch(FormatException)
{
error = true;
}
finally
{
if(error)
{
MessageBox.Show("Please enter a valid number");
textBox.SelectAll();
textBox.Focus();
e.Cancel = true;
}
}
} When the user tries to take focus away from the control, its contents will be validated. If invalid, the user won't be allowed to leave the control unless he corrects it or leaves it empty.
Then in you button handler, just validate that the text boxes have anything. If they do, it's surely a valid number.
I hope this helps!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
In keypress of textbox-es write this code:
e.Handled = e.KeyChar < '0' || e.KeyChar > '9';
u are able to write only numers no other charachters
I hope this helps u
|
|
|
|
|
I have a value in the ComboBox that does not appear in its drop down list. When I drop down the list, I want the nearest match to be selected without changing the current value.
So far I have a custom control that I inherited from System.Windows.Forms.ComboBox, and I have the following code attempting to do this.
protected override void OnDropDown(EventArgs e)
{
string strValue = this.Text;
int nValue = Convert.ToInt32(strValue);
for (int i = 0; i < this.Items.Count; i++)
{
int nItem = Convert.ToInt32(this.Items[i].ToString());
if (nValue >= nItem && nValue < nItem + 50)
{
this.SelectedIndex = i;
break;
}
}
base.OnDropDown(e);
this.Text = strValue;
}
If I remove "this.Text = strValue;", the nearest value is selected however the Text property will now contain this new selected value. I want to select the nearest value when the list drops down (for display purposes), but at the same time retain the value in the Text property.
--IAN
|
|
|
|
|
Hope this helps...........
private string buffer = String.Empty;
private Timer timer = null;
const int MAX_BUFFERSIZE = 1024;
this.timer = new Timer();
this.timer.Interval=1000;
this.timer.Tick+=new EventHandler(this.TimerTick);
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OnKeyPress);
public void TimerTick(object sender,EventArgs eArgs)
{
this.buffer = String.Empty;
this.timer.Stop();
}
protected void OnKeyPress(object sender, KeyPressEventArgs e)
{
try
{
e.Handled = true;
if ( this.buffer.Length == 0 )
{
timer.Start();
}
if ( buffer.Length < MAX_BUFFERSIZE )
{
buffer += e.KeyChar.ToString();
Console.WriteLine(buffer);
}
int startIndex = 0;
if ( this.SelectedIndex != -1 )
{
startIndex = this.SelectedIndex;
}
bool found = false;
for ( int index = startIndex; index <= this.Items.Count - 1; index++)
{
string text = String.Empty;
if ( this.DisplayMember != String.Empty )
{
PropertyInfo propertyInfo = base.Items[index].GetType().GetProperty(base.DisplayMember);
text = propertyInfo.GetValue(base.Items[index], null).ToString();
}
else
{
text = base.Items[index].ToString();
}
if ( text.Length > this.buffer.Length )
{
if ( text.ToUpper().StartsWith(buffer.ToUpper()))
{
found = true;
this.SelectedIndex = index;
break;
}
}
}
if ( !found )
{
for ( int index = 0 ; index < startIndex; index++)
{
string text = String.Empty;
if ( this.DisplayMember != String.Empty )
{
PropertyInfo propertyInfo = base.Items[index].GetType().GetProperty(base.DisplayMember);
text = propertyInfo.GetValue(base.Items[index], null).ToString();
}
else
{
text = base.Items[index].ToString();
}
if ( text.Length > this.buffer.Length )
{
if ( text.ToUpper().StartsWith(buffer.ToUpper()))
{
this.SelectedIndex = index;
break;
}
}
}
}
}
catch ( Exception ex )
{
Console.WriteLine(ex.Message);
}
}
|
|
|
|
|
Unfortunately I'm not looking for autocomplete type of functionality.
Let's say that combo box list contains times of the day in half hour increments (12:00 am, 12:30 am, 1:00 am, ...). This allows for easy selection of a time. However the user needs to be allowed to enter a time that does not appear in the list, say 1:09 am (and actually by default will be loaded with the current time). This is all easy to do, and does not require any extraordinary coding.
Now for the tricky part. Let's say the combo box has a value of, say 3:12 pm. When the user clicks to drop down the list, the value 3:12 pm will not be found in the list, so it will be positioned with 12:00 am as the first item in the drop down list. Just as a nice to have, I'd like to see the list "auto-scroll" to the nearest value contained in the list when the list is dropped down. In this case it would be 3:00 pm. In addition, at the same time as we are "auto-scrolling", we need to retain the original value of 3:12 pm in the combo box. I know, quite a challenge.
Microsoft currently has this type of functionality in Outlook when setting up a new appointment on the Calendar. If they can do, should we be able to do it?
--Ian
|
|
|
|