|
Okay, here's a simplified version of what I'm trying to do.
I have a RichTextBox in a form for editing a text file; I've written a simple Find/Replace dialog (whose parent is the textbox itself).
Currently, when you hit "Find", it has to close the dialog so that you can see the selected text (selected by the RichTextBox.Find function). You can then use F3 to find again. If a RichTextBox doesn't have focus then the selection isn't visible, so there's no benefit to keeping the dialog open.
But what I'd really like to do is keep the Find/Replace dialog open while someone does as many find and replaces as they want.
Any ideas out there?
Paul
And you run and you run to catch up with the sun, but it's sinking Racing around to come up behind you again The sun is the same in a relative way, but you're older Shorter of breath, one day closer to death - Pink Floyd, Time
|
|
|
|
|
Try passing a reference to your RichTextBox to the find form, and calling the RichTextBox.Find method from the actual find form. Make sure you use the Show() method to open your find form, rather then the ShowDialog() method.
|
|
|
|
|
Do any free .NET grid controls exist?
-Domenic Denicola- [CPUA 0x1337]
“I was born human. But this was an accident of fate—a condition merely of time and place. I believe it's something we have the power to change…”
|
|
|
|
|
So far ive only seen two, the one in the C# section of this site, and the other is one that i am working on, gone a bit on the back burner now, but i intend to put a little more effort into its production.
[Davide Icardi] http://www.codeproject.com/useritems/CSharpGridControl.asp[^]
[Mine] http://www.onyeyiri.co.uk/csharp/grid/[^]
[edit]
shouldnt of mentioned mine, no where near ready.
[/edit]
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
When you move a splitter with the mouse, a pointy black/grey background of the splitter is painted. This I would like to change.
I tried to use the Splitter_Moving event, but it doesn't work. Maybe my painting was overpainted from System.
Does anybody know how to change this or can give me a tip?
Thanks
Stefan
|
|
|
|
|
You can't that easily. The splitter window is drawn using an hardcoded private function :
private void DrawSplitHelper(int splitSize) {
Rectangle local0;
IntPtr local1;
IntPtr local2;
IntPtr local3;
IntPtr local4;
if (this.splitTarget == null)
return;
local0 = this.CalcSplitLine(splitSize, 3);
local1 = this.ParentInternal.Handle;
local2 = UnsafeNativeMethods.GetDCEx(local1, IntPtr.Zero, 1026);
local3 = ControlPaint.CreateHalftoneHBRUSH();
local4 = SafeNativeMethods.SelectObject(local2, local3);
SafeNativeMethods.PatBlt(local2, local0.X, local0.Y, local0.Width, local0.Height, 5898313);
SafeNativeMethods.SelectObject(local2, local4);
SafeNativeMethods.DeleteObject(local3);
UnsafeNativeMethods.ReleaseDC(local1, local2);
}
As you can see, the implementation never takes care of properties you may have set (like ForeColor, ...).
The only way to get around this is to write your own splitter window. But that requires significant work since all of the splitter methods are declared private, thus won't be inherited.
Using a decompiler however, that's not a complex task.
Good luck!
|
|
|
|
|
Thank you.
So it's possible but very difficult? So I can't derive from SplitterClass and than overwrite the DrawSplitHelper?
What do you mean with "write your own splitter window"? Do you mean to take the panel-class and than write the whole Splitter Functionality by my-self? That would be hard, wouldn't it?
It seams that you know really much about C#. Can you give me a tip or a direction how to solve this problem with the Splitter?
Thanks
Stefan
|
|
|
|
|
STW wrote:
So I can't derive from SplitterClass and than overwrite the DrawSplitHelper?
You can derive the class since it's not internal nor sealed but, since almost all methods are private, by inheriting the class you won't get them. (that's a basic inheritance rule).
STW wrote:
What do you mean with "write your own splitter window"?
I mean "write your own splitter window".
The splitter class is a System.Windows.Forms.control derived class, so basically you have to do exactly that, and implement all the stuff. Fortunately, the .NET splitter class is much simpler than the MFC Splitter Window (which acts as a container and provides a lot of implementation for scrollbars, etc.). Using your own implementation, almost the only thing you have to do is to provide OnMouseDown, OnMouseMove and OnMouseUp handlers, and call the native WIN32 SetCapture()/ReleaseCapture() whenever needed.
That said, although I haven't tried it, I would simply try to override Splitter.WndProc(ref Message m) and implement my own WM_PAINT handler. Just in case...
Good luck!
|
|
|
|
|
Hi again,
This code is for sorting the numbers which are given randomly in an array.
private void BubbleSort(int[] a) {
for ( int i = 0; i < a.Length - 1; i++ ) {
for ( int j = 0; j < a.Length - i - 1; j++ ) {
if ( a[j] > a[j + 1] ) {
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp; }
}
}
}
private void sort_Click(object sender, System.EventArgs e) {
const int count = 1000;
Random r = new Random();
int[] a = new int[count];
for ( int i = 0; i < count; i++ )
a[i] = r.Next(1000); //numbers 0 - 999
BubbleSort(a);
for ( int i = 0; i < count; i++ ) {
richTextBox1.AppendText( a[i].ToString() + " " );
}
}
}
I want to ask why we used the second for loop can't we do it with only one "for loop"?
And why we substracted i(int) in the second loop's condition?
Kind Regards,
-
kromozom@msn.com for MSN Messenger
-
|
|
|
|
|
Yes Pal,
It's very much possible. Just see the code snippet.
private void Swap(int arr[], int pos1, int pos2)<br />
{<br />
int tmp = arr[pos1];<br />
arr[pos1] = arr[pos2];<br />
arr[pos2] = tmp;<br />
}<br />
<br />
public void BubbleSort(int arr[])<br />
{<br />
int ctr = 0;<br />
while(ctr<arr.GetLength(0)-1)<br />
{<br />
if(arr[ctr1] > arr[ctr1+1])<br />
{<br />
Swap(arr, ctr, ctr+1);<br />
ctr=0;<br />
continue;<br />
}<br />
ctr++;<br />
}<br />
}
U could use a for loop too if u want.
Hope this helps!
regards
Atul Kale
MCSD, MCT
Sr. Software Engineer
XcelVision Technologies Ltd.
|
|
|
|
|
oh, thanks buddy.
This is another(better I think ) way to do a sorting.
However I couldn't understand the while loop there?while (ctr)? and thanks again
If you wish you can add me into your MSN contact list(if you are using it )
-
kromozom@msn.com for MSN Messenger
-
|
|
|
|
|
Hey, I'm sorry, that code was a Copy Paste mistake. Since it was HTML it didn't understand the code in less than and Greater than signs. It took it as an HTML tag! Here's the rectified one.
private void Swap(int arr[], int pos1, int pos2)<br />
{<br />
int tmp = arr[pos1];<br />
arr[pos1] = arr[pos2];<br />
arr[pos2] = tmp;<br />
}<br />
<br />
public void BubbleSort(int arr[])<br />
{<br />
int ctr = 0;<br />
while(ctr<arr.GetLength(0)-1)<br />
{<br />
if(arr[ctr1] > arr[ctr1+1])<br />
{<br />
Swap(arr, ctr, ctr+1);<br />
ctr=0;<br />
continue;<br />
}<br />
ctr++;<br />
}<br />
}
Atul Kale
MCSD, MCT
Sr. Software Engineer
XcelVision Technologies Ltd.
|
|
|
|
|
oh, allright sometimes Copy&Paste can cause problems . I understood the while loop here now. Thanks again for your help.
-
kromozom@msn.com for MSN Messenger
-
|
|
|
|
|
I have a string.I want to store it in my database as BINARY,and then get it from database and convert it to string.So how can I convert string to binary and convert binary to string?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
have tried it out.. ;P;) ~
|
|
|
|
|
System.Text.Encoding
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Thanks.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Hi all:
I hav problems when I try to connect to a Exchange Server with MAPI. The situation is as follows:
I have Exchnage Server in one machine and the ASP.NET application that access it in another machine. In order to logon I use this:
oSession.Logon(strUser, strPassword, False, True, 0, True, strProfileInfo)
and it connects. But when I try to access to any resource in the exchange (the inbox, for example) the next error appears:
"The information store could not be opened. [MAPI 1.0 - [MAPI_E_LOGON_FAILED(80040111)]]"
I think this is because access restrictions or something like that. Anyone has an idea of what is happening?
What is the best way to work against Exchange with this architecture (Exchange Server in one machine and ASP.NET application in another?
Any help will be apreciated.
Cheers,
Ivan
|
|
|
|
|
Hi,
I have have a form that is a child control in a panel. I would like to prevent anyone from moving this form. I have already set the form so it's not resizable.
Is there any way to lock the form to prevent it being moved.
Thanks!!
Stefan
|
|
|
|
|
You could fire the LocationChanged event and place the form back to orginal location.
Point OriginalLocation;<br />
private void Form1_Load(object sender, System.EventArgs e) {<br />
OriginalLocation = new Point(this.Left,this.Top);<br />
}<br />
<br />
private void Form1_LocationChanged(object sender, System.EventArgs e) {<br />
this.Location = OriginalLocation;<br />
}<br />
|
|
|
|
|
i have already draw many rectangle inside a form how can i move the rectangular form one position to another after i have selected the rectangular to move.
|
|
|
|
|
You can do this by changing the Rectangle Draw points and then redraw the object.
<br />
Rectangle DrawRectangle = new Rectangle(4,4,50,50);<br />
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {<br />
e.Graphics.DrawRectangle(System.Drawing.Pens.Beige, DrawRectangle);<br />
}<br />
<br />
private void button1_Click(object sender, System.EventArgs e) {<br />
DrawRectangle = new Rectangle(20,20,50,50);<br />
panel1.Invalidate();<br />
}<br />
|
|
|
|
|
thanx for your tips.i want to ask i have a lot of rectangle in the form how can i know which rectangle i have select to move and can i remain the size of the rectangle when i move and can i see the effect of the move when i move the rectangle.thank you for help me answer the question.
|
|
|
|
|
Hello All,
I get this warning:
The keyword new is required on 'MyNamespace.MyClass.Client' because it hides inherited member 'System.Net.Sockets.TcpClient.Client'
On this piece of code:
public TcpClient Client {
get { return Client; }
set { Client = value; }
} I'm not really sure what it means though. The public TcpClient Client is where the error occurs, but this is a property and I don't want it to return a new TcpClient everytime someone gets this property. The public TcpClient Client is initialized in the constructor for the class.
public MyClass ()
{
Client = new TcpClient ();
} I don't really want to just leave the warning so any ideas on what to do would be very much appreciated.
On a separate note is there any way to make the compiler treat warnings as errors?
Many thanks in advance.
- monrobot13
|
|
|
|
|
I had a thought after I posted this message. Could the source of the problem simply be that I have a property named Client and so does the base class TcpClient ?
- monrobot13
|
|
|
|