|
|
I want to store the edit position of a richtextbox and set the position back after I renewed it's contents.
Thanks.
|
|
|
|
|
I believe the SelectionStart property stores where the caret is, if there's no selection.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
OK; I tried ClickOnce, and that didn't work. How would I send a program with some DirectX and audio files in an eMail? Thanks.
- I love D-flat!
|
|
|
|
|
* In a zip file
* In a self extracting zip file
* As an MSI file
* as a link to a download
A lot of corporate mail systems will block attachments that it sees as dangerous. So EXEs and MSI files prossibly won't get through. ZIP files are also often searched by email scanners so if those files are found in there also it will get blocked.
|
|
|
|
|
Well, I see, but every time I send, it always says I'm missing files (or, the other person sees that...). So is there anything I need to include?
- I love D-flat!
|
|
|
|
|
Well, your first step would be to make sure the person on the other end has DirectX and .NET installed. Then zip up the files from the directory where you run them ( so they are in the right folders ), rename the zip to zip1 or something if need be ( to avoid it being rejected ) and send
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Is there anyway to add that to the packge, because I'm pretty sure they don't have anything that I do with resources.
*Also, to let people know, I hope to find a true programming class within a year or two, so I can finally get REALLY going.
- I love D-flat!
|
|
|
|
|
I am writing an HR application to add new employees. Currently, I am having an issue where I want to send a specific message base on the exception that is received. In my database SNN is a unique key hence if an SSN is being added that already exist in the DB a Unique key violation exception is thrown. If the UserID already exist a Primary Key violation exception is thrown. I am certain this is possible but just not sure what is best practice. I can write a method which search the DB first and if the record is found thrown an error message based on whether it was the Unique key violation or the PK violation. I have also been searching MSDN to see if I can identify the C# SqlClient error ID for either scenarios and based on the exception ID, alert the user with the right error message.
Any advice will be greatly appreciated.
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
Skanless wrote: I have also been searching MSDN to see if I can identify the C# SqlClient error ID for either scenarios and based on the exception ID, alert the user with the right error message
All the Ids can be found in SQL Server itself.
SELECT * FROM sys.messages or
SELECT * FROM sysmessages (if you are on SQL Server 2000)
|
|
|
|
|
Thanks dude, I found them. I would still like to know what best practice for a situation like this.
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
Use IF Exists in a trigger and then throw custom exceptions from the sp. However, SQL server will natively through the message number so there is no reason for custom handling to catch it.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
This worked perfectly!!!
IF EXISTS
(SELECT Emp_Login_ID FROM Employees where Emp_Login_ID = @Emp_Login_ID )
RETURN -1
ELSE
IF EXISTS
(SELECT Emp_SSN FROM Employees where Emp_SSN = @Emp_SSN )
RETURN -2
ELSE
INSERT INTO........
I am no longer receiving the Exception. However, I am not sure how to throw the Error message in C#. How would C# know to throw and Exception if the insert does nto execute? Thanks for you help.
Note: All this is done in a single stored procedure. Which is then called in the application in a try, catch statement.
Skan
If you knew it would not compile why didn't you tell me?!?!?!
modified on Thursday, December 06, 2007 12:44:52 AM
|
|
|
|
|
Thanks for the help guys. I got it working with the following lines of code. I will simplify my code later but just need to get it working.
SqlParameter paramReturnValue = new SqlParameter();
paramReturnValue.ParameterName = "@return_value";
paramReturnValue.SqlDbType = SqlDbType.Int;
paramReturnValue.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(paramReturnValue);
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
A System.Data.SqlClient.SqlException has an Errors array which contains the specific error(s).
I search it for 2601 (unique index violation) or 2627 (primary key violation), and if present I wrap it in a custom exception.
You can take a look at my DatabaseAccessor article which contains an enum of the code I support.
|
|
|
|
|
Hello everybody scenario is as follows:
Application multithreaded in windowsForms
C# Language
Framework 2.0 in VisualStudio 2005
This application works with several business logic processes asynchronous manner.
Play audio and video with DirectX
Handles timers who control the times of execution.
Everything works correctly while not use objects pictureBox with animated images (GIF). When I need to load an Animated Gif in a pictureBox and view the animation at run time, the processor is fired at a 100%, that happens only with a lively Gif image. Using a JPG or PNG static images, the performance is not affected. But implementation requires at least play 10 Gif animated, distributed in the Form.
When you try to load all these images, many are not displayed in the pictureBox and those displayed lose animation or reproduce them too slowly and with a delay that makes Losing the aesthetics chart.
To accomplish this I found some documentation msdn Class ImageAnimator, which to deploy in a component created for myself, I get the same problem of performance that picture box.
If anyone has an idea of what's going on and how to solve am waiting for their early comments.
Thankyou.
|
|
|
|
|
I'd avoid the picture box and draw the images yourself. The picture box doesn't handle animated gifs, so you must have your own code in there somewhere already, right ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i am trying to export a excel file to the user when they click a button, i tried Response.WriteFile("filename"), it only display the content in the same page, can someone tell me whats the code to prompt them with a save as option? Thank you in advance.
|
|
|
|
|
I think I just answered this in the VB forum. The ASP.NET forum is the only forum that is right for this question, please don't crosspost
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
sorry for the crosspost, i was a bit impatient, and thank you for your help, Regards!
|
|
|
|
|
Hi
I have the code below to minimize my form to the systemtray and bring it back up when the notifyicon is doubleclicked.
When the form is minimized some log-information is added in a richtextbox and I want the errors to be shown in red, so I set the selectioncolor to red.
My problem is that this only works if the form is in it's normal state otherwise all the text added will be black.
Does anyone know why I can't set the selectioncolor when the form is minimized?
private delegate void UpdateInfoDelegate(string newEvent, Color c);
private void UpdateInfo(string newEvent, Color c)
{
rtbInfo.SelectionColor = c;
rtbInfo.AppendText(newEvent);
rtbInfo.SelectionColor = Color.Black;
}
public void SetInfoText(string text)
{
rtbInfo.Invoke(new UpdateInfoDelegate(UpdateInfo), DateTime.Now + " " + text + "\r\n", Color.Black);
}
public void SetErrorText(string text)
{
rtbInfo.Invoke(new UpdateInfoDelegate(UpdateInfo), DateTime.Now + " " + text + "\r\n", Color.Red);
}
private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
Hide();
notifyIcon1.Visible = true;
}
}
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
Show();
WindowState = FormWindowState.Normal;
notifyIcon1.Visible = false;
}
|
|
|
|
|
You have to do the append/coloring in this order: append, select appended text, set selection color. See this post on MSDN[^].
|
|
|
|
|
I have a dataset filled with names (1 table 1 collumn),
I then loop trough the dataset and add all of them as tree nodes to a treeview.
Then i want to aply a rowfilter after the rowfilter is set i want to loop trough the filtered set,
But evertime i do it nothing gets filtered it just displays everthing in the dataset.
I'm guessing that its my loop but im not sure:
for(int i=0; i < dataset_filter.Tables[0].Rows.Count; i++)
Rowfilter:
dataset_filter.Tables[0].DefaultView.RowFilter = "filter='" + filter.Text + "%'";
Thanks!
|
|
|
|
|
Hello,
I am executing a JScript class from my C# using Microsoft Jscript Engine, using reflection to invoke JScript.
If there is any exception thrown from JSCript, how to frame it properly for end user. I can handle the execption in try catch block, but i am getting TargetInvocation exception, which needs to be framed properly and shown to end user. Any Inputs in framing the TargetInvocation exception and showing to user in meaningful way?
Thanks
|
|
|
|
|
Hello,
I have a DataGridView that is dynamically populated and configured for row select, multiselect = no. When a row is double clicked, an event handler is fired which runs a function based on the Row index. The row index is referenced as follows:
myDgv.SelectedRows[0].Cells[2].Value.ToString()
This works great, until the user is holding the CTRL key while double clicking. I get an "index out of range error", making me think holding the CTRL key changes the value the above code returns.
Has anyone ran into this before? I'm not sure what to do, other than catch the error and fail the event. Any ideas are appreciated!
Thanks,
Alan
|
|
|
|