|
The fact that you're targeting the .NET CF is something you should've mentioned up-front. We can't help you if you don't give us all the necessary details. The other poster could've avoiding posting about the Append method if he/she knew that you were targeting .NET CF (and either knew off-hand that it wasn't available or bothered to check the documentation before giving faulty information).
Look for my answer on the other responses.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for the answer but I'm using the .NET compact framework in which TextBox.Append does not exist.
Any suggestions for a solution for the .NET compact framework?
Do I have to look for API native code solution?
Thanks.
avivhal
|
|
|
|
|
I'm sorry, didnt know Append wasnt available in all environments. I'm not really sure if there is a simple solution to your problem without the Append method. I'll check around because I'd swear I saw this crop up somewhere else and maybe somedoby came up with a solution that didnt involve the Append method.
I'll Let u know if I find anything.
|
|
|
|
|
Hi, Thanks for your help.
I searched all over the web and could not find a solution/idea how to solve this.
Hope you'll find a solution.
I dont think there is a simple one. I'll probably have to implement a control that uses API dll functions to fix this issue in the .net compact framework.
Please let me know if you find something.
Thanks.
avivhal
|
|
|
|
|
Would it be too "dirty" to use the clipboard and the Paste() method of your Textbox? that seems to do the job.
I dont know if Paste is available to you in your environment...never did anything with PDA's and such.
|
|
|
|
|
The SelectedText , SelectionStart , and SelectionLength properties are defined for TextBoxBase (from which TextBox derives) for the .NET CF, so you can mimic what AppendText does.
What does it do? Use ildasm.exe if you know how to read IL or get a decompiler like .NET Reflector and find out.
Basically, you're looking for something like this:
public class MyTextBox : TextBox
{
public void AppendText(string text)
{
int len = TextLength;
SelectionStart = len;
SelectionLength = len;
SelectedText = text;
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks,
I also noticed that any key event leaves the caret in its position, but when I try to add/append text programaticaly not from within a key event, the caret jumps to the beggining of the TextBox.
Is there any way to add the text from outside those events (that is not by a key clicked but by data received from other data source e.g. a serial port) and keep the caret from jumping to the beginning of the TextBox?
Thanks
avivhal
|
|
|
|
|
That's why you assign SelectionStart then SelectionLength (in that order). If that's not working for you, then you'll need to move the caret by P/Invoking SendMessage and sending EM_SETSEL message (0x00b1) to the Window handle (the Handle property on every control).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Great,
This should do it.
Thanks for your help.
avivhal
|
|
|
|
|
Don't you mean AppendText()? And won't it still be necessary to use SelectionStart? Something along these lines, perhaps:
private static void AddSomeTextToThisTextBoxPlease( TextBoxBase textBox, string someText )
{
int selectionStart = textBox.Text.Length;
textBox.AppendText( someText );
textBox.SelectionStart = selectionStart;
}
Or are you saying AppendText() leaves the cursor where it is? The documentation doesn't seem to say anything regarding that detail.
Matt Gerrans
|
|
|
|
|
I'm using the .net compact framework (I develop this for a pocket pc) in which AppendText does not exist.
It works fine in the full .net framework.
Aviv.
avivhal
|
|
|
|
|
AppendText is the only Append* method defined on or inheritted by TextBox , but it is not defined in the .NET CF.
Normally, no, you do not need to change the selection start since that is handled internally.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Sorry I did not mentioned that I was refering to the .NET CF
My mistake.
Anyhow, I get data from an serial driver I wrote for the PDA and I want to present it in the TextBox.
Since the append method does not exist and I do need to add the data received from the driver to the TextBox, I use :
TextBox.Text += RecievedText;//RecievedText is the data received from the driver
This line of code causes the caret to jump to the beggining of the TextBox.
Thanks for your reply.
avivhal
|
|
|
|
|
Thats exactly the problem I have.
Any key drivven event will respond well.
I wonder what does the .NET framework do to make it work...???
Aviv.
avivhal
|
|
|
|
|
Would it be too "dirty" to use the clipboard and the Paste() method of your Textbox? that seems to do the job.
I dont know if Paste is available to you in your environment...never did anything with PDA's and such.
|
|
|
|
|
It is a bit to "dirty" for me.
I wish I knew what does the .net framework do after a key event?
Then we would have the solution....
Thanks.
avivhal
|
|
|
|
|
Hi,
I have a question to the File.Copy methode.
I use this methode within a timer. Every 10 minutes the timer copies some files to another directory. After that another methode opens and makes some changes in the copied files.
The problem is that the application changes the files before they have been copied yet.
How can I fix this problem?
Marius
|
|
|
|
|
You need to synchronize your methods. When the timer elapses the method is executed in a separate thread that executes asynchronously with the rest of your application. Do get around this there's many classes in the System.Threading namespace you should read about, like a Mutex or a Monitor . C# also defines the lock keyword to lock against a static object (so your copy and modification code should lock against the same object), which compiles down to a Monitor .
The not-so-obvious gotcha is that you should allow queues for the locked object to timeout. If a file copy operation takes 30 minutes for some reason, you could have a couple of requests for the locked object in order to modify the file. Now, maybe this is desirable (to make sure the changes get in there, but to ensure that those changes are updated you really should look into better serialization approaches in case your app dies for some unexpected reason).
Here's an example:
static object sync = new object();
private void Copy()
{
lock (sync)
{
}
}
private void Modify()
{
lock (sync)
{
}
} Again, if you want more control over how your code is synchronized then take a look at the other classes in the System.Threading namespace in the .NET Framework SDK, which is installed by default with VS.NET and is available online at http://msdn.microsoft.com/library[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Use Mutex to wait until the first method finishes the copy process.
You may also use a flag in your class to indicate whether the copy is in-progress or finished and have the modify method wait until the copy is finished. However note that the first solution is clean and neater to maintain the code.
Salil Khedkar [^]
|
|
|
|
|
I've been wandering what is the difference between a richTextBox and a regular (multiline in this case). also, how do I actually use the saveFileDialog control to save the textbox's contents to a file.
|
|
|
|
|
Difference between the two is just about the same as the difference between Notepad and Wordpad. Open them up and play around to see. The RichTextBox support RTF formatted files as well as normal text files.
The SaveFileDialog doesn't do any saving what-so-ever. It's a dialog box that lets the user pick a path and filename that your code uses to do the actual saving of data. Let me repeat this -> YOUR CODE MUST SAVE THE DATA. The SaveFileDialog will not do this for you!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have an XmlTextReader that is reading through a document, I get a start element with the name that I am looking for
call reader.Read to get inside data
and reader.ReadString() to get the text.
This works fine except for a case where I want the text to contain some HTML
the html looks like "firststring <-> secondstring"
I am storing it as XML like "firststring&nbsp;&lt;-&gt;&nbsp;secondstring"
but the reader only gets firststring on the call to ReadString()
is there a way I can get the complete string in a single call, changing the & to &?
Thank You
|
|
|
|
|
I have a page (ASPX) that has a grid on the left side and an embedded web control (ASCX) on the right side. The ascx contains lots of textboxes,labels,etc.
I have added Get/Set properties for each of the controls in the ascx code-behind file. I want to pass data retrieved from the selected row in the grid to the textboxes in the ASCX. Here's a snippet of the code;
ASPX code-behind:
protected DeficiencyReport DeficiencyRpt1; //reference to ASCX
DeficiencyRpt1.SPRTextBox= "value"; // set new value
Property in ASCX:
public string SPRTextBox {
get {return SPR.Text;}
set {SPR.Text=value;}
}
Everything works fine except that the value is not displayed in the textbox. Can anybody tell me what I'm missing?
Tony N
|
|
|
|
|
Your question belongs in the ASP.NET forum.
And next time please be patient when posting instead of posting the same three question three times. The site is slow to repond at times. If you would've been buying something you would've just bought 3 copies of it. The lesson is be patient. If a site is going to err it will tell you (or the browser will tell you).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I am building a table of about 100 schools and school numbers using dataadapter. The table has three columns: schoool name, school number and index. Index is an identity column and the primary key. This database table is empty when I start.
I create a dataset of the schools and insert rows to the table but when I try to update it, only the first record is inserted and the update fails on the second insert because of duplicate key in the identity column. Here is the code:
DataSet1 ds1 = new DataSet1();
public int AddSchools(string [,] strSchoolList)
{
for (int i=0; i<200; i++)
{
if (strSchoolList[i,0] != null)
if (strSchoolList[i,0] != "")
{
ds1.Schools.AddSchoolsRow(strSchoolList[i,0],strSchoolList[i,1]);
}
}
sqlDataAdapter1.Update(ds1);
return 0;
}
If I configure the dataadapter without the identity column, it cannot autogenerate the update and delete commands. But with the identity column it will not let me add a value to the index column as in:
ds1.Schools.AddSchoolsRow(strSchoolList[i,0],strSchoolList[i,1],i);
I can work around this problem, but someone out there must know the proper way to handle this situation.
|
|
|
|