|
SelectionLength = 0;
That's the first thing that came to my mind. There are also arguments in the 'e' parameter that you can use. Cancel pretends the keydown never happend, sometimes called Suppress.
|
|
|
|
|
<br />
private void textBox_Receivers_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
textBox_Receivers.SelectionStart = 0;<br />
textBox_Receivers.SelectionLength = textBox_Receivers.Text.Length;<br />
textBox_Receivers.SelectionFont = new Font("Arial",8,FontStyle.Regular);<br />
textBox_Receivers.SelectionLength = 0; <br />
}<br />
doesn't work...hm
cu
|
|
|
|
|
richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength = richTextBox1.Text.Length;
richTextBox1.SelectionFont = new Font("Arial", 8, FontStyle.Bold);
richTextBox1.SelectionStart = richTextBox1.Text.Length;
richTextBox1.SelectionLength = 0;
This works fine when I do it.
|
|
|
|
|
hi, thx perfect, but i have a problem
if i select the whole text in the richtextbox and press clear or backspace then the whole text isn't cleared...hmmm!?
but i think i also can do that with Rtf, i mean that with underline...? how?
i saw:
<br />
textBox_Receivers.Rtf ...<br />
by the time i like c# *hehe*
cu
|
|
|
|
|
Rtf is just the same text but with the formatting codes included. You would never want to set the font on your Rtf. The codes will never be seen. If you're asking how to do underline, it's part of the FontStyle just like Regular and Bold.
|
|
|
|
|
if i select all the text in the richtextbox and if i press clear or backspace then all the text isn't cleared...hmmm!?
why?
cu
|
|
|
|
|
Come on, that one is pretty obvious don't you think?
|
|
|
|
|
I need to know how would i remotely call methods on another pc(program) when my database(sql) changes(update occurs).I need to notify my viewing program(GUI) of the changes allowing immediatly show the changes as the database changes. How would this be done in C#. Triggers? I am very new to C# links to some nice tuts would be helpful as well as any other suggestions on how i would tackle this. Thank you
|
|
|
|
|
There are plenty of ways I'm sure, but I've always had the best success with custom TCP protocols. Meaning, you would connect to the remote computer through a TCP Client on a dedicated port, and send your own message format to the remote computer. The remote computer should have a thread that is constantly listening on that port for new connections. When it receives your connection, it verifies that it came from you (your custom message format should have a username/password in it), and performs the necessary operation based on the message. This approach has yet to fail me.
|
|
|
|
|
that sound great, is there perhaps some links to samples explaining in more detail, as i said i am new to programming. thanx again
|
|
|
|
|
If you've never set up a TcpClient, studio 2005 makes it pretty easy. Same for the TcpListener on the remote computer.
//DataBase Computer
TcpClient m_connection = new TcpClient("15.3.6.33", 17534);
StreamWriter m_writer = m_connection.GetStream();
m_writer.WriteLine("(app)(username)mel(/username)(password)mel(/password)" +
"(command)REFRESH(/command)(/app)");
//Remote Computer
TcpListener m_listener = new TcpListener(17534);
TcpClient m_connection;
StreamReader m_reader;
String strCommandText;
m_listener.Start();
while(true)
{
if (m_listener.Pending())
{
m_connection = m_listener.AcceptTcpClient();
m_reader = m_connection.GetStream();
strCommandText = m_reader.ReadLine();
// Now parse your message to find out what you should do.
}
}
-- modified at 18:16 Tuesday 30th August, 2005
|
|
|
|
|
Hi there,
I'm writing a Client/Server program that relied on Tcp Communication.
the problems begin when one of the clients that already connected to the server decide to disconnect (shut down the program or because of an error).
the thing is that before he decide to disconnect his status is "Connected" (at the database)
and after that, when the client has disconnected, the socket keeps on being opened for at least 60sec because of that the client cannot reconnect to the server
(and because the server couldn't tell if the client has been disconnected or not so his status is still "Connected").
What can i do?
can i raise any event that will tell the server that one of the clients has disconnected himself?
pls, need help...
thanks...
|
|
|
|
|
I have still not seen any events that you can listen for when it comes to the socket class. What I do is to have a thread that is dedicated to doing nothing other than checking my array of socket connections. If it ever finds a connection that was closed from the remote end, it calls the necessary method. That's with C#.. I've done development in C++ with QTSockets, which do (God bless them) have events for socket disconnection.
|
|
|
|
|
Hi!
The TcpClient has timeout properties and a LingerState property that controls if and for how long the underlying socket is kept open.
Perhaps twiddling with these will help you closing the socket immediately.
Regards,
mav
|
|
|
|
|
I want to convert the CR & LN characters to and from their decimal values.
so I would have a text variable set to "\r" and/or "\n" and I would want to display these values to the user as "13" and/or "10". Allow the user to changes these to other decimal values and convert back to the text equivalent for searching in strings.
I have the convestion from decimal to character as follows, but what about the other way around ?
string Data = INI.GetINI("Settings","Seperator","/13/10");
string [] Seps = Data.Split('/');
string m_Sep=null;
foreach(string Sep in Seps)
{
if(Sep.Length==0)
continue;
m_Sep += (char)int.Parse(Sep);
}
|
|
|
|
|
Converting is easier than you think. Just use basic byte-char conversion:
char one = '\r';
byte val = (byte)one; //result is a 13
char two = (char)val; //result is '\r'
|
|
|
|
|
|
hi,
i want to recognize numbers:
0676xxxxxx
0664xxxxxx
must always begin with 0676 or 0664 .....
how can i test if the numer is between 6-9 digits?!?
<br />
Regex regex = new Regex(@"[(0664),(0676),(0699),(0650),(0660),(0688)][0-9]+?");<br />
Match m = regex.Match("213613213");<br />
<br />
if(m.Success)<br />
{ <br />
MessageBox.Show("True");<br />
}<br />
else<br />
{<br />
MessageBox.Show("False");<br />
}<br />
why the messagebox with true comes here?
cu
|
|
|
|
|
Your regular expression is equivalent to:
"[(),0456789][0-9]+?"
or
"[(),0456789]\d+?"
Use {6,9} to detect 6 to 9 occurances.
The Match method only checks if a match can be found inside the string. that means that the string "some text 0664123123 more text" will still be valit. If you want to match the entire string, you have to include the start of the string (^) and the end of the string ($).
This should be closer to what you want:
"^06(76|64)\d{6,9}$"
---
b { font-weight: normal; }
|
|
|
|
|
|
perfect now it works!
where can i read more about regex, in msdn ther's not very much!!
detect 6 to 9 occurances:
regex = new Regex(@"^06(76|64|50|60|68|69)\d{6,9}$");
is 6-9 here valid for the whole string
because of:
Match m = regex.Match("06761234567"); -> (m.Success) == true ....
cu
|
|
|
|
|
This is probably the best book about regex you can get:
http://www.amazon.com/exec/obidos/tg/detail/-/1565922573/104-5681665-2239906?v=glance
The {6,9} is only valid for the \d.
If you need it for the whole string you would need to do something like this: (regex\d{2,5}
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
I am trying to use a foreach to loop through a few datasets to update a table. With the code I have it is not working. I have checked both datasets with the quickwatch to make sure they are populated and they are. It runs through the code once, but on the second time through I get an error that the "SqlHelper.ExecuteScalar(Session["connect_string"].ToString(), System.Data.CommandType.Text, update).ToString();" statement, "Object not set to reference". I inserted a breakpoint and found that the Session variables are not changing in the update statement that I am creating. Any help would be appreciated.
foreach(DataTable mbTable in mb.Tables)
{
foreach(DataRow mbRow in mbTable.Rows)
{
Session["id"] = mbRow["m_id"].ToString();
Session["order"] = mbRow["m_ord_number"].ToString();
string dtdate = "SELECT stp_arrivaldate FROM stops WHERE ord_hdrnumber = '" + txtOrder.Text + "'";
DataSet dt = new DataSet();
dt = SqlHelper.ExecuteDataset(Session["connect_string"].ToString(),
System.Data.CommandType.Text, dtdate);
foreach(DataTable dtTable in dt.Tables)
{
foreach(DataRow dtRow in dtTable.Rows)
{
Session["dtdate"] = dtRow["stp_arrivaldate"].ToString();
string update = "UPDATE masterbrand_appt SET m_delivery_date = '" + Session["dtdate"].ToString() + "' WHERE m_id = '" + Session["id"].ToString() + "' AND m_ord_number = '" + Session["order"].ToString() + "'";
SqlHelper.ExecuteScalar(Session["connect_string"].ToString(),
System.Data.CommandType.Text, update).ToString();
}
}
}
}
Scott Moore
|
|
|
|
|
Why are you using session variables in this way? I can see nothing but trouble coming from that.
I suppose that you only get one record in the result from the select query? Why do you loop through all of the tables (a single one) and all of the rows (a single one)?
---
b { font-weight: normal; }
|
|
|
|