|
hi,
I am creating a editor in Richtextbox control.
and now i want to implement feature Undo and redo ..
I am not getting it.
pls help me
with regards
prasad
|
|
|
|
|
Check out this recent code project article.
Standards are great! Everybody should have one!
|
|
|
|
|
Here are some articles:
http://www.codeproject.com/useritems/useractionbasedundoredo.asp
http://www.codeproject.com/csharp/autoundoredo.asp
and this pattern looks promising too:
http://en.wikipedia.org/wiki/Memento_pattern
Although they will not be easy to implement with a RichTextBox I think.
A simple solution, that comes to my mind would be to save a copy of of the text when a change occurs. Then you can undo by replacing the current one with this copy. You should however limit the number of copies because it will consume a lot of memory when there is a lot of text.
Can you show us what you have thought of, or have tried already? Do you have a specific problem, or just no idea where to start?
I feel like a twat :p I didn't know RichTextbox has Undo/Redo functionality. Post your code, tell us what the problem is.
-- modified at 10:38 Wednesday 21st March, 2007
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
hi,
int ActiveUndoIndex = ActiveWindowStatus();
if (arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.CanUndo == true)
{
arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.Undo();
arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.ClearUndo();
}
this code is undoing the enitre actions not chracter by chracter ...
help me pls
|
|
|
|
|
Before you try to Undo something, you need to check to see whether or not it can be undone. To do this, you need to call CanUndo and only call Undo if it returns true. Similar logic applies to Redo/CanRedo.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi,
int ActiveUndoIndex = ActiveWindowStatus();
if (arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.CanUndo == true)
{
arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.Undo();
arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.ClearUndo();
}
this is undoing the entire operation
e.g if i enter 100 chracters
it is deleting 100 chracters at time for single undo..
|
|
|
|
|
hi
The Richtextbox control have methodes for this issues
e.g. Copy(), Paste(), and properties like CanCopy or CanPaste
regards
|
|
|
|
|
Search the articles for "undo" and/or "redo". There are some that cover this topic.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I could only find an example in VB.
http://www.java2s.com/Code/VB/GUI/RichTextBoxReDoandUnDo.htm
this is my own mockup
private void button1_Click(object sender, EventArgs e)
{
if(richTextBox1.CanUndo)
{
richTextBox1.Undo();
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
button1.Text = richTextBox1.UndoActionName;
}
It seems to work fine here.
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
hi,
int ActiveUndoIndex = ActiveWindowStatus();
if (arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.CanUndo == true)
{
arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.Undo();
arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.ClearUndo();
}
this is undoig all entered characters at single shot
e.g if i enter 100 charcters all 100 chractes are removing at a single shot.
|
|
|
|
|
can i install a software from client machine to server with the help of .net remoting concept. i try to install a software. it installed the server but it use the registry of client machine?
sree
|
|
|
|
|
hello,
i need to convert wav file to mp3.
there are several types of bit rates. normally use 8kpbs to 320kpbs.
most project using lame dll. can i convert this without lame dll.
could u please explain the bit rates as mentioned above.
sree
|
|
|
|
|
Why you want to work without lame dll?
About bitrate vales.. I found this:
32 kbps: radio AM quality
96 kbps: radio FM quality
128 to 160 kbps: Decent quality
192 kbps: Good quality
224 to 320 kbps: Like CD quality
Cheers,
Russell
|
|
|
|
|
you can, have lots of fun reading the mp3 spec and experimenting to find the least lossful ways to do encoding. Most projects use a 3rd party encoder because doing this in a way that sounds good is not an easy task.
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
I want to build a webcontrol that has a reference to seperate controls on the page to manipulate them on pre-render. Does anyone know how to do this. Because I can not find any articles about it.
|
|
|
|
|
Hello frineds
in this code I wanted when I add 2 nums,the result be shown in another massagebox(plus in textbox in form)
I wanted to use predefined "Click" Please guide me.
namespace calculate
{
public delegate void Startdelegate();
public delegate void addnum();
public partial class tamrin : Form
{
// custom event
public event Startdelegate StartEvent;
private Form2 Form2;
public tamrin()
{
InitializeComponent();
this.Load += new System.EventHandler(this.Form1_Load);
StartEvent += new Startdelegate(OnStartEvent);
StartEvent();
}
button2.Click += new EventHandler(OnClickadd);
private void button1_Click(object sender, EventArgs e)
{
int result = int.Parse(num1.Text) / int.Parse(num2.Text);
MessageBox.Show(result.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
int result = int.Parse(num1.Text) + int.Parse(num2.Text);
TextBox3.Text = result.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
int result = int.Parse(num1.Text) * int.Parse(num2.Text);
MessageBox.Show(result.ToString());
}
public void OnStartEvent()
{
Form2 = new Form2();
Form2.Show();
}
public void Form1_Load()
{
Form3 = new Form3();
Form3.Show();
}
public void Onclickadd()
{
int result = int.Parse(num1.Text) + int.Parse(num2.Text);
MessageBox.Show(result.ToString());
}
}
}
|
|
|
|
|
For a method to qualify as an eventhandler, it must have object sender and e eventargs as parameters.
f.e.:
form1.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
...
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
MessageBox.Show("test");
}
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Hello
I want to change this method
public void Onclickadd()
{
int result = int.Parse(num1.Text) + int.Parse(num2.Text);
MessageBox.Show(result.ToString());
}
So that it can be used by predefined "Click" event.
How?
|
|
|
|
|
hi all,
i need to display, image and other text coloms in ListBox/DataGridView
please anyone suggest me to how to go with this?
regards
prashanth
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
pashitech wrote: i need to display, image and other text coloms in ListBox/DataGridView
DataGrid[ ^] sample for datagrid having different types of data objects in the cells.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hi everyone. I'm trying to use SPI_SETWORKAREA to reserve some space down the side of the screen for my application.
Everything works fine as far as other applications go (the space is reserved so that a maximised window doesn't cover the area, for example) but the desktop itself isn't affected. That is to say, icons on the traditional Windows desktop don't obey the new work area, meaning half of them end up underneath my window.
The code I'm using is as follows:
{
RECT R;
R.Left = 300;
R.Top = 0;
R.Right = Screen.PrimaryScreen.WorkingArea.Right;
R.Bottom = Screen.PrimaryScreen.WorkingArea.Bottom;
IntPtr p;
p = Marshal.AllocHGlobal(Marshal.SizeOf(R));
Marshal.StructureToPtr(R, p, false);
SystemParametersInfo(SPI_SETWORKAREA, 0, p, 0);
int ret = Marshal.GetLastWin32Error();
}
RECT OriginalScreen;
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
I know I can achieve all of this (including resizing the desktop icon area) by creating an AppBar, but would rather use the SETWORKAREA if possible. Has anyone got any suggestions? I'm running this on Vista if that makes any difference. Thanks in advance!
|
|
|
|
|
Is there a guide somewhere on the net about the layout of a form (windows or web)?
I'm searching more along the line of best practices or guidelines about placing the OK/Cancel buttons, tab order, placing the controls in a good manner, etc...
Searching google, Msdn and CP didn't deliver anything useful.
thanks !
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
V. wrote: Is there a guide somewhere on the net about the layout of a form (windows or web)?
Here[ ^] is one for web design tips.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
thanks
|
|
|
|
|
Welcome
Knock out 't' from can't,
You can if you think you can
|
|
|
|