|
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.
|
|
|
|
|
For inserts don't insert values from DataTable s into the database. Instead, insert only non-auto-generated field values and add a SELECT statement (separated by a semi-colon) after your INSERT to make sure the DataTable has the correct data from the auto-generated fields. This is what the command builders do automatically, which the visual designers also make use of. It is also recommend throughout the .NET Framework SDK documentation.
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]
|
|
|
|
|
Heath, I don't understand your advice at all. I'm using Visual Studio to autogenerate most of the code. I drag a dataadapter from the tool box onto a component designer and use the "generate dataset" from the "data" drop down menu. For the insert, I just update the dataadapter after adding new rows to the table with the data to be inserted. I don't even have access to the identity column. The actual code is listed in my first posting.
|
|
|
|
|
If the command builder didn't recognize the identity columns (and that's possible based on what OLE DB driver you're using) then it could include the identity columns in an insert. Just because VS.NET built the code doesn't mean you shouldn't review it. Expand the auto-generated #region in your source file and ensure that no auto-generated columns (like an auto-incrementing ID column) isn't inserted into the database).
If you're using OleDbDataAdapter then it may not work to combine an INSERT and SELECT statement into the InsertCommand property. You'll need to Update the database with the adapter first, then re-Fill the DataSet .
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 have a TreeView with nodes at only two levels. I want to add a ContextMenu and change the contents of the context menu depending on the node that is right-clicked. I am using the Popup event to change the content of the context menu as is common practice.
The problem is that the instant the user right-clicks a node, the node is highlighted, but in reality does not becomes the selected node. In fact, TreeView.SelectedNode contains a reference to whatever the previously selected node is. This is very confusing to the user, because it sure looks like the node he has right-clicked has becomes selected. However, programatically I cannot determine (thru TreeView.SelectedNode) which node was right-clicked.
Has anyone run into this? Any work arounds?
Thanks!
Mark Mokris
|
|
|
|
|
This is the work around I used:
private void tvTreeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
try
{
if(e.Button==MouseButtons.Right)
{
TreeNode tn = tvTreeView.GetNodeAt(e.X,e.Y);
if(tn==null)
return;
tvHL7TreeView.SelectedNode=tn;
}
}
catch(Exception Err)
{
throw new Exception("MouseDown: "+Err.Message);
}
}
|
|
|
|
|
Thanks a million! That worked great!
Mark
|
|
|
|
|
how do I have a machine refresh the user policies? I know there's a registry key to do this, but it seems to me there should be a better way, as the system doesn't even rescan that key often enough to know how often to refresh policies.
2ndly: how do I send text to a textBox on the next line of the textBox, without deleting any previous data in it.(this is a multiline textBox) (I'd prefer to not have to send previous contents to a variable and then insert them, as there should be a better way). also, is there a way to add the line numbers to each row of text in a text box.
thanks a bunch,
Stephen
|
|
|
|
|
check out the documentation on secedit.exe, this should allow you to update the Group Policies on a particular machine.
|
|
|
|
|
I couldn't get the thing to refresh my policy settings on my own machine even after changing them with gpedit.msc (I tried disabling regedit and the control panel). this didn't even work plus, I need to be able to incorporate these commands into my c# app. (I don't know how to use the command prompt via a c# program).
|
|
|
|
|
In order to force the refresh of Group Policies, you can call the API functions, defined in UserEnv.dll, RefreshPolicy or RefreshPolicyEx.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
incorporating the comand into your C# app is easy.
Just use the Process class. It has a static method Process.Start("command here") where the string represents the executable to run.
|
|
|
|