|
Assign all of the child controls keypress events to the forms keypress event handler. Note that this would not actually raise the forms event. If you needed that you may be able to call the forms keypress event (using the RaiseEvent statement) from the event handlers of each of the controls.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
The problem with that, is that the KeyPress events don't seem to work on the User controls that edit their Graphics. (Button Click events do, but I need keypress events.)
That's why I was hoping there's some way of making shortcut keys from the parent form.
- Munty
|
|
|
|
|
Enable the KeyPreview property on the form, then handle the forms KeyDown/KeyPress/KeyUp events. The form will get first look at the key events before they're sent to the child controls.
|
|
|
|
|
Hi Dave,
Thanks for the reply. That was exactly what I needed.
Silly thing is, is that I had already tried that, and it didn't work the first time. Then after you suggested it, I decided to try it again. But I've got it working now
- Munty
|
|
|
|
|
i have a file has extention DAT
i write string line in this file
but when i read this line from the file it doesn't return string
this is the code i wrote
StreamWriter OpenToWrite = new StreamWriter("Connection.DAT");
OpenToWrite.Write(@"server="+txt_servername.Text +";database=NewWay;User ID="+txt_username.Text +";password="+txt_password.Text);
OpenToWrite.Flush();
OpenToWrite.Close();
StreamReader OpenToRead = new StreamReader("Connection.DAT");
string Conn = OpenToRead.Read().ToString();
thnx for help
MD_NADA
|
|
|
|
|
md_nada wrote: string Conn = OpenToRead.Read().ToString();
You would need to use the overload method Read(char[],startindex,length), this would store the value as a char array and you can read the value from that. You can use string conn = OpenToRead.ReadLine() instead.
This method of storing the user name and password in a text file doesn't seem to be a good way. You could use app.config to store the server name and the database name. You should probably be passing the username and password from the login screen or something like that. Atleast encrypt the password your storing in the dat file.
|
|
|
|
|
I'm not willing to debug your code, but here is a good example.
Read Text From/Write Text To a File (VB.NET)[^]
Note the code at the bottom of the page defining the functions GetFileContents and SaveTextToFile. Those functions correctly show how to handle the streamreader and streamwriter classes.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Hi,
I am trying convert Text to HTML. i am able to do this using the webbroswer control. My problem is something like this.. After assigning some text to the Webbrowser control i am not able to copy the contents from it immediately. But when i add a message box before copying or do the copy in a different event it works fine... i guess its something to do with the refresh, plz help me solve this. Below is the code i am trying.
<br />
IHTMLDocument2 doc;<br />
public WebBrowser browser;<br />
constructor..<br />
{<br />
browser = new WebBrowser();<br />
}<br />
<br />
click event..<br />
{<br />
browser.DocumentText = "This is a test message<br />
<br />
//With this line contents are available. I want to do this without this line.<br />
MessageBox.Show("Test");<br />
<br />
doc = (mshtml.IHTMLDocument2)browser.Document.DomDocument;<br />
Clipboard.Clear();<br />
doc.execCommand("selectall", false, null);<br />
doc.execCommand("Copy", false, null);<br />
RichTextBox r = new RichTextBox();<br />
r.Paste();<br />
Clipboard.Clear();<br />
MessageBox.Show(r.Text.ToString());<br />
}
|
|
|
|
|
I suspect the browser isn't fully initialized yet. Try calling DoEvents in place of the messagebox. I seem to remember a BrowserState or ReadyState property you can check as well. Check the state and wait until it is ready.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Thank you so so soooooo much... That absolutely saved my day.
|
|
|
|
|
Is there a way in C# or C++ to determine if given file is Binary or Non-Binary. There are some forums which suggests to check the bytes of file and look for null byte. Is there any other way around?
Any help would be appriciated.
|
|
|
|
|
|
Hi,
all files are binary, some contain text (in ASCII, Unicode, whatever), some
contain an image, or some other kind of data.
So you might have to clarify your question.
|
|
|
|
|
Of course, all files are Binary, but i want to differentiate files based on the printable characters they contain. Basically, i need it for a utility which would compare two files and write the differences between them to third file, or may update one file by comparing it to the others. I can only tell this much. Since, such comparision for "binary" files like DLL, Jar etc are meaningless i wanted to identify them before i compare them. I can't change the utility i will use for such comparision. I wrote following method, which i think would work fine. Do you think it would work across all character sets? I am just reading file byte by byte and looking for a byte which is zero. Then i know that the file is binary.
static bool isBinary(ref BinaryReader binaryReader) {
bool nullByteFound = false;
int i = 0;
byte unsignedByte;
while (i < binaryReader.BaseStream.Length) {
unsignedByte = binaryReader.ReadByte();
if (unsignedByte == 0){
nullByteFound = true;
break;
}
i++;
}
Console.WriteLine("Bull= " + nullByteFound);
return nullByteFound;
}
The other API IsTextUnicode may also help in solving problem if i retrieve IS_TEXT_UNICODE_NULL_BYTES flag. Thanks all for your help on this.
|
|
|
|
|
Hi,
if a text file is encoded using ASCII or ANSI or some other 8-bit character set,
then zero-testing looks acceptable.
if a text file is encoded using some 16-bit encoding scheme, then zero bytes
can occur in text files (e.g. the char 0x0100, 0x0200, etc).
You could check the first few bytes of the file, Unicode/UTF8/UTF16 use special
values here; if these match you might assume it is text and skip further
testing (and once in a while such assumption will be wrong);
if they dont match you could assume it is an 8-bit encoding, and do the zero test.
Whatever you do, since 100% confidence will not be achievable, I see no point
in checking more than a few hundred bytes before deciding text/no text.
|
|
|
|
|
I am doing a Project that is in ASP.NET 2.0 and C# with SQL Server 2000 on Windows XP.
through Programming I am creating a PDF document and inserting some values into that.After that I am sending this PDF doc in mail attachment to some mail ID.
initially PDF was corrupting and one page was corrupt.(Error was cooming :An error exists on this page.Acrobat may not display the page correctly.Please
contact the person who cretaed the PDF document to correct the problem.)
Then I used UUEncoding then Mail attchment was comming properly to other mail accounts like yahoo etc.but it was cooming to gmail account in plain text format instead of attchment.
what's wrong I am doing???
What is the solution for that??Plz help me in this regard as soon as possible.
you can mail me at adil@vsoftconsulting.com
adil kazmi
|
|
|
|
|
It would have been better for you to delete the post without a response to it already.
|
|
|
|
|
Hmm,
At first it was just a decision between one of the two post.
Which can of course be a hard decision.
Because they where all the same, and maybe the one which is going to be choosen, will be angry afterwards.
Than somebody made it clear by answering one of the posts.
So decision was not too far away.
But than in the last second totally confusion by exactly the same post which should make it clear first.
"Please delete one of your posts"
I'm not sure if I would have choosen the correct one in this situation
|
|
|
|
|
Hi all
Can anybody tell me how to create a dockable toolbar in C#. I neet it very urgently. Please help me.
Regards
Sagar Pattnayak
Sun-Dew Solutions
9831169962
|
|
|
|
|
|
Is it possible to have a single handler for all the context menu items.
In fact I know that all clicks to a context menu can be captured by the event "ContextMenu_Click"
But how do we know which menu item was clicked?
Thanks in advance
Deepu
|
|
|
|
|
Deepu AM wrote: how do we know which menu item was clicked?
by examining the sender parameter
|
|
|
|
|
Thank you for your reply Giorgi.
But the only options available for "sender" parameter are
Sender.Equals()
Sender.GetHashCode()
Sender.GetType() &
Sender.String()
I cant figure out how to get the menu item which was clicked using these methods.
Please help.
Thanks
deepu
|
|
|
|
|
You should cast the sender to the appropriate type.
|
|
|
|
|
Thank you for helping Giorgi
|
|
|
|