|
I see what you mean... perhaps hold an internal variable that remembers if the selection was right-to-left or left-to-right (a bool would do). Then do an if/else on it.
Left selected:
if (rightToLeft)
{
textBox1.SelectionStart--;
textBox1.SelectionLength++;
}
else
{
textBox1.SelectionLength--;
}
Right selected
if (rightToLeft)
{
textBox1.SelectionStart++;
textBox1.SelectionLength--;
}
else
{
textBox1.SelectionLength++;
}
|
|
|
|
|
Thanks for the suggestion, but my control is only one of several possibilities to set the selection and I still don't know how to initialize rightToLeft .
For the moment I went for the "send Shift+Ctrl+Left/Right" solution (that's working at least), but still I'd be interested if someone found out a better way...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Have you tried going backwards?
Messages.SelectionStart = Messages.Text.Length;
Messages.ScrollToCaret();
|
|
|
|
|
I'm not sure if I understand what you mean.
ScrollToCaret() moves the visible part of the textbox but I need to adjust the selection...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
If you create a <[yourAppName].exe.config> file like the one below,
you will see extra "socket" debug tracing information.
However when I try to do this programmatically (below),
I don't see any trace info.
<<<
TraceSource ts = new TraceSource("System.Net.Sockets", SourceLevels.Verbose);
ConsoleTraceListener consoleListener = new ConsoleTraceListener();
consoleListener.Name = "console";
ts.Listeners.Add(consoleListener);
>>>
The question is why?
Can it be done programmatically?
Here's the config file that works...
<configuration>
<system.diagnostics>
<sources>
<source name="System.Net.Sockets" switchValue="Verbose">
<listeners>
<add name="console" type="System.Diagnostics.ConsoleTraceListener"> </add>
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
|
|
|
|
|
I received this from Microsoft.
To configure you the listeners and level of logging for a listener you need a reference to the listener that is going to be doing the tracing. Your call to create a new TraceSource object creates a trace source with the same name as the one used by the System.Net.Sockets classes, but it's not the same trace source object, so any changes do not have an effect on the actual TraceSource object that System.Net.Sockets is using.
Because of this, you'll need to use the application configuration file to enable the trace.
The tracing config settings lets you listen to messages from a trace source (in this case from Socket classes) but the TraceSource instance itself remains private and inaccessible directly/programmatically. Think of it this way – you don’t want to grant direct access to your trace source instance and let someone send messages under disguise but you do want to allow operations to configure what level of information you trace and where you trace etc…
|
|
|
|
|
Hello all,
I am trying to call a javascript function from a Link Button.
<asp:LinkButton OnClick = "javascript:popupwin(VrNo=<%#DataBinder.Eval(Container.DataItem,"IDD")%>,1,frmClient.HiddenClientId.value)" ID="lnkViewDetails" runat="server">View Details</asp:LinkButton>
But i am getting a follwing error while switching to design view "The server tag is not well formed"
Where is the problem ??
Please help ...
|
|
|
|
|
use the LinkButton onClientClick
|
|
|
|
|
Thanks for your reply but still there is same error.
"The server tag is not well formed."
|
|
|
|
|
have you got runat=server in your tag?
Have you got a closiing tag?
Paste the tag here and I'll have a look at it for you
|
|
|
|
|
<asp:LinkButton OnClick = "javascript:popupwin(VrNo=<%#DataBinder.Eval(Container.DataItem,"IDD")%>,1,frmClient.HiddenClientId.value)" ID="lnkViewDetails" runat="server">View Details</asp:LinkButton>
This is my tag for Link Button..
|
|
|
|
|
Heya,
I'm having problems creating a custom group control (which I'll call XPanel for now). I'd like XPanel to be a user control consisting of several sub-panels, that the XPanel user can add their own child controls to.
I have two problems with this:
1) If I add an event handler to the XPanel.ControlAdded event that transfers the added control to one of the sub-panels, I get an error in a message box at design time: "'child' is not a child control of this parent". This doesn't happen if I create and add the control at run-time.
2) How do I allow the sub-panels to be selectable at design time? Will I have to write my own design-time painting and interaction code? At the moment, the XPanel appears as a big indivisible unit when I add it to a form.
Thanks in advance!
Andy
|
|
|
|
|
I've just tried and I can add sub-controls to 'XPanel' in the VS-designer without issue if I inherit XPanel from Panel instead of UserControl . No ControlAdded event handling required.
|
|
|
|
|
Hi Bob,
Thanks! I think I wasn't clear about it, though - I have no problem inheriting XPanel from Panel and adding child controls, but that's not quite what I want.
XPanel has N child panels S1..SN, that could look like this:
<br />
+-XPanel------------+<br />
|...................|<br />
|.+-S1--+...........|<br />
|.|.....|...........|<br />
|.+-----+..+-S2--+..|<br />
|..........|.....|..|<br />
|..........+-----+..|<br />
|...................|<br />
+-------------------+<br />
If the user of XPanel adds an instance to a form, I would like her to be able to add controls to XPanel.S1 or XPanel.S2, instead of to XPanel directly.
Which is why I wanted to handle ControlAdded, so I could pass controls added to XPanel on to XPanel.S1 or XPanel.S2.
Thanks again,
Andy
-- modified at 10:35 Monday 29th January, 2007 (got inheritance order wrong
|
|
|
|
|
Hi,
is there a wax to tell the compiler to ignore a warning for a region of code, like it is possible in C++ like this:
#pragma warning( disable : 4705 )<br />
...
#pragma warning( default : 4705 )
Thanks for Help
Greets
Roland
|
|
|
|
|
See this article on MSDN
#pragma warning disable 4705
and
#pragma warning restore 4705
Gruß
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank,
but it looks like it is a feature added in .net 2.0. is there a way to do the same in .net 1.1 as i am stuck to it for this project...
Greets
Roland
|
|
|
|
|
What is the warning that you are trying to ignore?
---
Year happy = new Year(2007);
|
|
|
|
|
The Warning CS0067: The event 'event' is never used.
It is caused by a class dummy created for a test that implements an interface that contains this events. As some events are not relevant for the test they are not used.
I can live with it but it would be nicer to have a 'clean' build.
Greets
Roland
|
|
|
|
|
You can write a protected or private OnEvent method. Its not that much code and should be done quickly even for some events by copy-and-paste. Furthermore, the methods may be useful, if you later on add more intelligence to the dummy or implement the final class.
private void OnEvent(EventArgs e)
{
if (this.Event!= null)
this.Event(this, e);
}
"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
|
|
|
|
|
thank u for answering but i wish to still send the string until i click the cancel button . these ways (while 1==1) , while(true),... keep the program not responding. i have to do task manager and stop the program can u help me to solve this problem?again this is my code . thank u all.
private void OK_Click(object sender, EventArgs e)
{
string str;
ExceptionLabel.Text = "";
sp.BaudRate = 9600;
sp.DataBits = 8;
try
{
if (sp.IsOpen == false)
sp.Open();
str = "*" + fan.Items[fan.SelectedIndex].ToString() + "&" + light.Items[light.SelectedIndex].ToString() + "@" + water.Items[water.SelectedIndex].ToString() + "#";
sp.WriteLine(str);
textBox.Text = str;
}
catch (System.Exception ex)
{
ExceptionLabel.Text = ex.Message;
}
}
private void cancel_Click(object sender, EventArgs e)
{
sp.Close();
this.Close();
}
|
|
|
|
|
Create your loop in a new Thread .
And don't open a new topic, you can continue the discussion in your previous topic.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I suggest you use a timer (preferrably a System.Forms.Timer) to periodically perform
your serial port stuff once, have your OK button start the timer and your Cancel button
stop te timer.
Alternatively, provide a bool variable "portRunning"; let your start button set
portRunning true and make it create a new thread that contains a while(portRunning) loop
with your serial port stuff, and let your Cancel button set portRunning false.
I prefer the timer approach since then you achieve an upper bound for the amount
of data that gets transmitted per second.
PS: none of these will run infinitely, your computer (or Windows) will come to an end sooner
or later...
Luc Pattyn
|
|
|
|
|
Hi, i wish to create an infinite loop to send a string to an I/O port infinitly can anyone help me please? my code code is:
private void OK_Click(object sender, EventArgs e)
{
string str;
ExceptionLabel.Text = "";
sp.BaudRate = 9600;
sp.DataBits = 8;
try
{
if (sp.IsOpen == false)
sp.Open();
str = "*" + fan.Items[fan.SelectedIndex].ToString() + "&" + light.Items[light.SelectedIndex].ToString() + "@" + water.Items[water.SelectedIndex].ToString() + "#";
sp.WriteLine(str);
textBox.Text = str;
sp.Close();
}
catch (System.Exception ex)
{
ExceptionLabel.Text = ex.Message;
}
}
private void cancel_Click(object sender, EventArgs e)
{
sp.Close();
this.Close();
}
|
|
|
|
|