|
Hi,
To send ASCII characters try
char c = 'c';
byte[] b = System.Text.Encoding.ASCII.GetBytes(new char[] { c });
port.Write(b, 0, b.Length);
This will work for any character, and GetBytes works for strings too. In order to send a decimal 205, don't use char but use byte instead.
|
|
|
|
|
hi all
i was playing around making a small image viewer app type thing (first foray into windows apps) and have run into a problem geting the child forms (or any off them for that matter) to communicate in a way I want, I'm not sure if its even possible, it should be as it seems to me to be a relatively fundamental use of them.
basically I was trying to get the mouse coordinates to update another child form that iwas going to use as a control, so ...the parent form opens the two child forms, one contains a picture anmd the other is just for info (the coords), I can pass the info over if I do a
MessageBox.Show("e.X.ToString());
however when I try to update, say a label it doesnt do anything. I imagine I'm doing something idiotic or missing something very basic, but like I said I'm jst on a learning curve atm ;0
in Form2.cs I have
<br />
private void OnMouseMove(object sender, MouseEventArgs e)<br />
{<br />
coordsPanel f = new coordsPanel();<br />
f.updateCoords(e);<br />
}<br />
and in coordsPanel.cs I have
<br />
public void updateCoords(MouseEventArgs e)<br />
{<br />
MessageBox.Show(label1.Text);
label1.Text ="foo";<br />
MessageBox.Show(e.X.ToString());
MessageBox.Show(label1.Text);
}<br />
the values getting across just not updating.
it works fine if its all in one form.
The label is declared as :
private System.Windows.Forms.Label label1;
I've tried using get/setand nothing seems to work.
I DON'T get any errorsand the app works fine so I'm not sure whats happening
any pointers appreciated.
t
|
|
|
|
|
sometimes (especially when you have a high cpu load) the controls do not invalidate (redraw, whatever ) though you change some of their values. In this case, you will have to use "System.Windows.Forms.Application.DoEvents()" - this static method allows you to let your application do all of the stuff in the queue.
I guess this won't be a solution for your problem because the interval between popping up a messagebox and clicking its "ok" button is enough time to get its events done...
try to add this statement first - if it does not work add a label1.Invalidate() which causes the label to redraw itself and all its child controls. (you also could invalidate the whole form to make sure everythings updated).
I guess this will help but i'm not sure at all.
Good luck,
mik
|
|
|
|
|
hi mik
i tried that but no joy im afraid.....
am playing with EventHandlers now to see if that help
t
|
|
|
|
|
erm i just noticed you set the labels text to "foo" EVERY time. you should change this to e.X.ToString() to set the labels text to the X position of the mouse.
|
|
|
|
|
hi
yeah i ended up just trying to get it do anything, its original text value is label1 and should change to foo. the message popups were just to see what was happening
|
|
|
|
|
|
Irfan Faruki wrote: Should i be using a Textbox or a Richtext control
Depends on how do you want to look and function your notepad
Irfan Faruki wrote: How do i go about replicating Find & Replace function
string objects have several functions that you might consider interesting:
- IndexOf - returns an integer greater or equal to 0 if what you seek is in the string, or it returns -1 otherwise
- Replace - replaces a part of a string with a new string (don't have to be the same length)
Irfan Faruki wrote: How do i go about replicating Go To function of notepad
if you use a textbox there is the Lines property which is a string array so you read the line number from the user and pass it as an indexer in that array.
Hope it helps you. Good luck
Do your best to be the best
|
|
|
|
|
Thanks a lot for your reply. I will give it a try and post back if i have problems
I am still learning
|
|
|
|
|
You know how each MSN messenger emoticon actually represents some text? Ok, to clarify, I made a simple form with 2 richtext boxes and 1 button which does the following:
<br />
private void btn_Ok_Click(object sender, EventArgs e)<br />
{<br />
DataFormats.Format MyFormat = DataFormats.GetFormat(DataFormats.Bitmap);<br />
DataFormats.Format MyFormat2 = DataFormats.GetFormat(DataFormats.Text);<br />
richTextBox1.Paste(MyFormat);<br />
richTextBox2.Paste(MyFormat2);<br />
}
First, I copy an image from say a word document. When I click on my button, the image appears in richTextBox1 but nothing appears in richTextBox2. However, if I copy a MSN Messenger emoticon, the emoticon picture appears in richTextBox1 and the corresponding text appears in richTextBox2.
Now my question is: So HOW do I embed that text into an image (like an emoticon) in the first place? Because obviously the emoticon has something more than a regular image.
|
|
|
|
|
Do you mean when you type " " and it replaces it with an image? Just parse the text then replace the substring " " with ""
|
|
|
|
|
Thanks but that's the problem i encountered. See, when a text is replaced with an image, the text is "lost". So say I have the string "Smile :p and cry . I can exchange the text for pic fine. The problem is when i want to "copy" this string onto another window without losing the text part. In the example above, i can only copy the picture or the text but not both. So i wondered how messenger is able to retain the text part in the image. Does it store a copy of the original text string in the background? But with this approach what happens when you delete a picture? How would the original string know what word you deleted?
|
|
|
|
|
Hi,
can any one help me in findout how to set validation for double field in property grid.
eg.
[Description("vet contain x"),Category("Vet")]
public double X { get { return FX; } set { FX = value; } }
here how can i set the max value for 'FX' which is double.
|
|
|
|
|
|
Hi,
I have problem with reading from serial port.
Even though the port is connected and a thumb impression is given as input
my program couldnt read. It produces System.TimeOutexception in the line
of code where i read from port. I couldnt get any idea how to get rid
form that.
The following is my code.please guide me whati have to change to get
the output.
If serialPort.IsOpen Then
serialPort.Close()
End If
Try
With serialPort
.PortName = ComboBox1.Text
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
End With
serialPort.Open()
MsgBox("SELECTED PORT IS CONNECTED")
Dim bufferpic As Byte = CType(serialPort.ReadLine, Byte)
Dim MemstrmPic As New IO.MemoryStream(bufferpic)
Form1.PictureBox1.Image = Image.FromStream(MemstrmPic)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Thanks in advance
|
|
|
|
|
I can open an excel woorkbook and select the sheet that i want to work with. After i have populated the sheet with data from a web front end i wish to display all the new data in a table on a webpage. I know in what range the data is on the worksheet but im having trouble writing it to the table. Can anyone point me in a right direction please ??
some code ...
Excel._Worksheet objSheet;
Excel.Sheets objSheets;
public void PopulateTable() {
objSheets = (Microsoft.Office.Interop.Excel.Sheets)Session["ExcelSheets"];
objSheet = (_Worksheet)objSheets.get_Item(3); /// 3rd worksheet in the workbook
Range PrintQuoteRange = objSheet.get_Range("A1", "E68"); //data from cell A1:E1 to A68:E68
//// display rows, col and cells in a table
//// ?????
}
|
|
|
|
|
You're on the right way
With this range you may fill a multidimensional array and put it into a table.
Just use the .get_Value() method of the range object to retrieve this array.
<br />
string [,] mydata = PrintQuoteRange.get_Value(System.Type.Missing);<br />
Now you have the whole Data in the array. A simple for loop will do the rest
Tell me if you keep having trouble with getting the data into a table.
I had to do something similar just 2 weeks ago and found this article very useful:
How to automate Excel by using Visual C# to fill or to obtain data in a range by using arrays
ATTENTION: if you want to set a value of a cell to more than 911 characters, you will get a com exception. To work around this issue just use the querytable instead (have a look at the COM forumpost i made recently)
However, good luck with automating Excel
(Let me know if you are not able to kill the excel process properly - i just found a nice article to get rid of this too )
|
|
|
|
|
Thanks alot! It worked 100% .... but it looks a bit tacky.
I wanted it to look just like the format in Excel. So i went back to the drawing board for a new solution i want to share just incase someone else does it too.
I copied the Excel sheet area i wanted to use and pasted it right in a new webform design view and saved it as Template.aspx . It looks exactly like the format in the excel sheet.
Now the for cells i want to populate, i just name then with html tags. I then use a normal streamreader to read the Template.aspx file and use my session variables to change the tags to the values i want ...... and viola !
Thanks again for the table solution above, atleast it worked too.
|
|
|
|
|
hi .
I want to know how can get clicked link in IE or other browser with c#.net .(I want arived url of a link with click on it)
computer
|
|
|
|
|
Hi,
Actually what you want to do?
If i am not getting you wrong, you want to hyperlink to some URL on click?
<marquee>nishu
|
|
|
|
|
Hi,
I am looking for a way to change the default WindowClassName of a .NET form into a custom one.
The default WindowClassName is .NET is: (VS.NET 2005/.NET 2.0)
WindowsForms10.Window.8.app.0.3ce0bb8
The reason is that I want to use FindWindow with a my unique class name, and currently I am forced to find the window by window title (very fragile solution).
In C++ it was very easy, but in .NET it seems to be deeply hidden in Windows Forms.
Anyone has a good hack/solution to this problem?
Thanks
Yuval
"The true sign of intelligence is not knowledge but imagination." - Albert Einstein
|
|
|
|
|
Hi,
I'm not entirely sure if this is what you're asking, but I find individual open forms in my application using this code block:
foreach (Form frm in Application.OpenForms)
{
if (frm is MyFormClass)
{
return (MyFormClass)frm;
}
}
Where MyFormClass is the class of the form I want to find.
Hope that helps.
ChrisB
|
|
|
|
|
Hi Chris,
I am asking to change the Window Class name.
Your solution find open forms inside a .NET process.
I am trying to find a window from another process. So there is no access to Application.OpenForms.
The API to do this is called FindWindow, it is a Win32 API.
In Win32 each window has a ClassName which is a classifier and nothing to do with C++/C# classes.
Use the Spy++ with .NET windows (forms) and you will see that the Window ClassName is not unique (all .NET forms have the same ClassName).
I simply want to customize this ClassName for my forms.
Thanks anyway.
Yuval
"The true sign of intelligence is not knowledge but imagination." - Albert Einstein
|
|
|
|
|
Hi,
I'm looking for a way to specify the port numbers of a TCP connection via a TCPChannel object. I use the TCPChannel because
I need to receive callbacks in my client application:
<channel ref="tcp" port="8085" rejectRemoteRequests="false" exclusiveAddressUse="true" useIpAddress="false">
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full"/>
<provider ref="secureHandshake" />
</serverProviders>
</channel>
The client instantiates the remote object in a common manner:
(ILogin) Activator.GetObject(typeof(LoginProvider), serverPath) // serverPath="....:7912"
Sysinternal TCPViewer tells me about the following established remoting endpoints:
Process Local Remote
Client.exe nb2h130c:8085 nbgh62091033:2147 // Connection#1 used for Callbacks
Client.exe nb2h130c:2176 nbgh62091033:7912 // Connection#2
Question:
Is there a way to specify the client port number (2176) of connection#2 and the number of the server port (2147)
Another strange behavior is, that these both connections will be periodically removed and new established with other port numbers, while client and server are still working without any problem.
In the internet, I only came across the information to set a fixed endpoint for COM+ applications.
Thanks for every reply
Thomas
|
|
|
|
|
I have made a deployment Setup Project in VS2005. I have two question reagrding it.
1. How can I check before the installation starts whether service pack is installed on the machine or not?
2. It generates a couple of files and folder. How can i package them into single self extracting executable file?
Any kind of help, suggestion or link would be highly appreciated.
Regards,
Wasif Ehsan.
|
|
|
|