|
This is C#, your string class has a split method. Try splitting on just \r, or just \n. The boxes you get in your list box make me think the rich text control is returning one of those two, and not both. So, call the split method and get a string array, use for each to pass them into the list box.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I did try to do the split on just /n or /r but no luck?
|
|
|
|
|
Just a sec, I'll whip up a project for you
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Your slash is the wrong way around. This works:
string text = richTextBox1.Text;
string [] strings = text.Split('\n');
foreach (string s in strings)
{
if (s.Length > 0)
listBox1.Items.Add(s);
}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You own man, thanks a bunch!!
Ron
|
|
|
|
|
If i open aFile in FileStream with FileAccess.Write, it is locked so i can't rightclick on it and copy or delete or move...
Is it possible in any way?
|
|
|
|
|
just simply close FileStream or ur application, then delete the file
<< >>
|
|
|
|
|
I have a C# application that acts as a socket listener.
I have another class that is built as a managed C++ dll that processes my data and sends the data back out to the connected client.
My question is, im having problems passing my active connection to the managed dll.
I did something like this:
C# side:
Socket socks;
//lets pretend its already connected, and accepted, huh
int success = ManagedMethod(ref socks);
C++ Side:
SOCKET *socks;
int ManagedMethod(Socket& act_sock)
{
socks = act_sock
}
cant remember what error it gives me, but I know its not right.
On the parameters of this method, I also tried 'Socket *act_sock' and still couldnt pass it.
My goal is to have my Managed C++ dll use this active connection after processing my data and send it to the connected client.
Thanks.
Steve Welborn
"Science can purify religion from error and superstition.
Religion can purify science from idolatry and false absolutes"
- 1987 John Paul the Great
|
|
|
|
|
Do you need to pass it as ref from C#? Remember, socks itself is a reference, so passing it by ref would require a pointer to a pointer on the MC++ side.
Assuming you don't need ref, this code compiles fine.
public __gc class Class1
{
Socket __gc * socket;
public:
void ManagedMethod(Socket __gc * s)
{
socket = s;
}
};
From C#, you can pass it as ManagedMethod(socks);
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks Senthil for the reply.
I guess I dont need it by ref, the only thing I needed was to be able to use the same instance of that Socket, with it staying connected and usable while being passed to my C++ dll.
So would the C# part be a regular passing of the connected Socket?
for instance:
Socket socks;
ManagedMethod(socks);
and does passing it like this allow the C++ portion to use it without reconnecting and accepting of client?
Steve Welborn
"Science can purify religion from error and superstition.
Religion can purify science from idolatry and false absolutes"
- 1987 John Paul the Great
|
|
|
|
|
I want to add a submenu to my programs context menu that will then show the standard Window's Explorer submenu.
Any ideas?
If anyone has ever used the program Tortoise CVS, it does such a thing. When you choose to Commit a set of files, right clicking on a file in the list displays the CVS menus, but there's also a submenu called Explorer. Highlighting this menu then displays a submenu just like you were in Window's Explorer and right clicked the file there.
help please..
|
|
|
|
|
Your best bet is to look into Windows Shell documentation and find out which Win32 calls (or possibly, Registry keys) can retrieve the list of Windows context menu options. That's the easy part. From there, you're gonna have to hook up your application to interop with the Windows shell; so that if you right click on some object in your program, it will allow you to, say, copy the file or text to the clipboard. That will be difficult.
I recommend you look for other options. What is it you want to do?
|
|
|
|
|
Hi,
I have a client application that I am writing that connects to a database (MySql) running a server on the network. I would like to be able to communicate from the server with any running client application to be able to send them messages (eg, the server is about to be rebooted, save your work now!). What would be the best way to go about this? I'm thinking that I could have my client listen using the TcpListener class to a port and write a quick and dirty app to run on my server that will use "show processlist" on the MySql server to find everybody who has a connection and send a message to them. Is this a good idea? I've never tried anything like this before.
Thanks
WJ
|
|
|
|
|
hi there,
below is just my idea:
1. write an server app on machine that MySQL is running on. this will listen on a port
2. ur client have to register itself to the server app after successfully connecting to MySql. So that the server app is able to know which clients are connecting to server
3. When the MySql is about to rebooted, just broadcast messages to all clients that are connecting to the server
<< >>
|
|
|
|
|
Thanks for your feedback. I'm going to have to ponder this a while...
|
|
|
|
|
Please anyone. How can I trap the delete key and handle it in such a way that the text in the richtext box will not be deleted.
thanks.
Nana
|
|
|
|
|
In your form, override ProcessCmdKey method. Then,
if(keyData == Keys.Delete)
{
return true;
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
|
Can anyone tell me how to fill more form up with rectangles? Like Grid sheet
say size 20 X 20
|
|
|
|
|
As I told you last time, override the OnPaint method and draw your grid using the Graphics.DrawLine method. Something like this:
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
Pen p = new Pen(Color.Black);<br />
int width = this.ClientRectangle.Width/20;<br />
int height = this.ClientRectangle.Height/20;<br />
int x = 0;<br />
int y = 0;<br />
for (int i = 0; i<20; i++)<br />
{<br />
e.Graphics.DrawLine(p,x,0,x,this.ClientRectangle.Bottom);<br />
e.Graphics.DrawLine(p,0,y,this.ClientRectangle.Right,y);<br />
x += width;<br />
y += height;<br />
}<br />
base.OnPaint (e);<br />
}<br />
Would work. It would need some cleaning up and you might want to make sure your form size will fit exactly 20 squares because otherwise the last row and column may be bigger than the others. Or you could draw a border around the grid . Whatever works for you.
|
|
|
|
|
Well, Thank you once again
|
|
|
|
|
Hi!
I doing an application that it is a coder, and other that is the receptor, and is the decoder (base 4).
I need that the application sends a message to domain (like net send, of cmd), and
i don't know how i have to do.
PLEASE!
HELP ME!!
Thanks...
|
|
|
|
|
The source is:
private void Form1_Load(object sender, System.EventArgs e)
{
password.Text = " ";
password.PasswordChar = "*";
}
private void SubmitPass_Click(object sender, System.EventArgs e)
{
if (id.Text == " USER " && password.Text == " PASSWORD ")
{
//here you have put the action that you want that the application
//do when login is true (for example)
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
//this action does that the window state application is
//maximized
}
else
//here the action that you want that the application would do
//if the login is false (for example)
MessageBox.Show ("Login incorrect. Try again","Login by Rugi",MessageBoxButtons.OK,MessageBoxIcon.Error);
//this action is because the application shows a critical (message box)
Visca Catalunya ||*||
Salutacions cordials:
Roger Roca
|
|
|
|
|
Can you write your question in english, please?
'A programmer ist just a tool which converts caffeine into code'
|
|
|
|