|
hi!
are you setting the Text property of your textbox?
if that's the case maybe the cursor or the SelectionStart property of the textbox resets to 0 or to the beginning.
try to set the SelectionStart to the end after setting the text.
hope that helps!
|
|
|
|
|
thnx for your reply, let me test
|
|
|
|
|
tb_Player_Messages.Text += _Message + "\r\n";
tb_Player_Messages.SelectionStart = tb_Player_Messages.Lines.Length;
Doesnt really work
|
|
|
|
|
are you having some event from the other controls before setting the text?
like for example, you have to click a button to append the text on your textbox?
if so, sorry but i forgot to tell you that you must call the Focus method of the textbox before setting the selectionstart.
because the focus is on the other control that's why it doesn't show the cursor on your textbox.
and also, instead of "tb_Player_Messages.Lines.Length" use "tb_Player_Messages.Text.Length".
<br />
tb_Player_Messages.Text += _Message + "\r\n";<br />
tb_Player_Messages.Focus();<br />
tb_Player_Messages.SelectionStart = tb_Player_Messages.Text.Length;<br />
i tried it and it works fine.
hope that solves your problem.
|
|
|
|
|
HI,
I have an animation flash file with .fla extension. I want to paly it in one of my form. How do I add it to my form.
Thanks.
|
|
|
|
|
I guees you can put Browser Control on your form ,then display in the control your flash file.
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
That worked !!!
Thanks a lot
|
|
|
|
|
Alternatively you could drop a Flash Player on your form. This might give you more control over playing of the movie and the ability to handle events from the control in your .NET code.
(Add it to the toolbar in VS by selecting it from the COM component list.)
|
|
|
|
|
Hi all,
I am wondering if it is really possible to get the selected text from the Embedded webbrowser control in C# application. It would be a great help.
Thanks and regards
Emran
|
|
|
|
|
This code snippet shows selected text in MessageBox.Don't forget to add reference to Microsoft.mshtml
<br />
IHTMLDocument2 HtmlDoc = (IHTMLDocument2)axWebBrowser1.Document;<br />
IHTMLSelectionObject selection = HtmlDoc.selection;<br />
IHTMLTxtRange range = (IHTMLTxtRange)selection.createRange();<br />
MessageBox.Show(range.text);<br />
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
Hi Tarsan,
I extremely appreciate your help.
I was trying to follow your tips but I faced two problem,
1] I am using Visual C# 2005 Express (.Net 2) and I dont see the DLL microsoft.mshtml is available for adding. I searched for this dll in google and i did not find it anywhere for download. So, if you have that, can you post that file here ?
2] Second question, I am using the control, "WebBrowser" (.NET 2005 Express edition comes with it), not the "Microsoft Web Browser". So, will your code work for this WebBrowser Control ?
Thanks and regards.
Emran
|
|
|
|
|
Hi Emran.
1) Yo can easy find microsoft.mshtml . Select "Add Reference" in "Solution Explorer" .Add component named "Microsoft Html Object Library" from "COM" tab. The DLL(COM) comes with IE and should be on your computer .
2)Yes, but with small changes and you still need microsoft.mshtml
<br />
IHTMLDocument2 HtmlDoc = (IHTMLDocument2)webBrowser1.Document.DomDocument;<br />
IHTMLSelectionObject selection = HtmlDoc.selection;<br />
IHTMLTxtRange range = (IHTMLTxtRange)selection.createRange();<br />
MessageBox.Show(range.text);<br />
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
Hi Tarsan,
I am really glad to know that my problem has a solution. I found the library in COM tab, but unfortunately everytime I tried to add that reference, my PC hung. But anyway, I will try and let you know if I had any problem to use that code. Till then, thanks and regards.
Emran
|
|
|
|
|
Hi Tarsan,
Thanks soooooo much, I am very happy to tell you that, your tips are working very nice.
First it did not work, I found that, if i place this header using MSHTML; at the top of the code, then it works.
Thanks again.
Emran
|
|
|
|
|
hi all
i am working in a MDI Application , and i want to disable the autoscroll property of the midi parent form, i had used this but it didnt work
public Form1()
{
InitializeComponent();
this.AutoScroll=false;
}
how to solve this?
|
|
|
|
|
|
very nice and it works good
many thx
|
|
|
|
|
Hi,
I have a stored procedure and it looks like the following
ALTER PROCEDURE USP_NCUInsertContentCodeTest
@var1 int,
@var2 int
etc
AS
DECLARE @RC int
//Do stuff
RETURN @RC
I know how to execute the procedure in c# but I cant figure out how to get the return value. I know if I declared the @RC before the AS I could declare it as a parameter with parameterdirectio = output etc but I cannot change the stored procedure. How can I do it?
Thank you in advance,
Ed
|
|
|
|
|
why not just do: Select @RC instead?
it will return a DataSet to c#...fill the DataSet using a sqladapter and then access the variable:
DataSet ds = new DataSet();
//Do stuff
int result = (int)ds.Tables[0].Row[0][0];
hope that helps
|
|
|
|
|
Sorry I dont know what you mean by do a select @RC
|
|
|
|
|
He means that in your stored procedure, instead of using a return that you do a
SELECT @rc If you don't SELECT anything else in the stored procedure then this can work quite well. In your C# application you would use ExecuteScalar() on the SqlCommand class in order to retrieve the result, like this:
SqlCommand cmd = new SqlCommand();
cmd.Connection = myConnection;
cmd.CommandText = "MyStoredProcName";
cmd.CommandType = CommandType.StoredProcedure;
int result = (int)cmd.ExecuteScalar()
Of course, if you are already returning other data from the stored procedure, this SELECT becomes a bit more difficult to manage. In that case you can retrieve the result by using a parameter to get the result of the RETURN statement.
In your command object add this to the list of parameters:
SqlParameter returnParam= new SqlParameter("RETURN_VALUE",SqlDbType.Int);
returnParam.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(returnParam); After you execute your stored procedure you can get the return value like this:
int result = (int)(cmd.Parameters["RETURN_VALUE"].Value)
int result = (int)returnParam.Value
Does this help?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
-- modified at 13:30 Monday 23rd January, 2006
|
|
|
|
|
Xodiak wrote: it will return a DataSet to c#...fill the DataSet using a sqladapter and then access the variable:
That is so much overkill!
int result = (int)mySqlCommand.ExecuteScalar(); That is all you need.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
interesting, how would you handle multiple variables returned(kinda like an output)?
|
|
|
|
|
Now you'd have to return those values as a dataset. Any stored procedure can only return one value using the return value method.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
To follow up on what Dave said (and, if I may quote Scotty in Star Trek V) use "the right tool for the right job".
You can also have a number of output parameters in the stored procedure.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|