|
After the call to InitializeComponent in the main form, add the following line:
SetStyle(
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer,true);
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
You're welcome.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm having trouble creating an 2007 Excel file from scratch using Microsoft.Office.Interop.Excel with C#.
Here is a part of my own class I'm using to create a non existing excel-file or open an existing excel-file
using Microsoft.Office.Interop.Excel;
public ExcelFile(string excelFile)
{
application = new Application();
if (!File.Exists(excelFile))
{
this.workbook = application.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
this.workbook.SaveAs(excelFile, XlFileFormat.xlAddIn8, "", "", false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, false, Type.Missing, Type.Missing, true);
this.workbook.Close(true, Type.Missing, Type.Missing);
}
this.workbook = application.Workbooks.Open(excelFile, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
}
Notice I check if the excel file exist on the computer before I use it.
If the excel-file don't exist I'm trying to create it, close it and open it so I can use it in my application.
But when I try to open it after creating it, the "application.workbook.open()"-method crashes in a COMException.
If I use an excel-file which already exist, the "application.workbook.open()"-method don't crash.
What do I miss? I used this page as source: http://csharp.net-informations.com/excel/csharp-create-excel.htm[^]
|
|
|
|
|
I do not know the answer to your problem but I would suggest that you paste the complete ComException message into the search box on one of the search engines. You will probably find lots of hits with the exact same problem and one of them may well have the solution.
After a quick glance at the link you provided, I noticed that you haven't quite implemented the complete solution. For example you have not 'Released' any of your objects after creating and closing the worksheet. Unless you do this, I suspect that the file will be considered 'in use' therefore causing the exception.
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
In the treeview, I want to display an image only on few nodes (not all). How do I do this?
Gurpreet
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:28am.
|
|
|
|
|
I am looking for showing image only on specific node. That does not work in this way. It shows image for all nodes or none.
Gurpreet
|
|
|
|
|
You can set the image index on individual nodes.
Node.ImageIndex
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You need to set the ImageIndex (and optionally, the SelectedImageIndex ) on the TreeNode you are interested in changing. If you only want to display an image on this node, you effectively have 2 choices - one is to add a dummy transparent image as the default image for the other nodes; the other is to change the ImageIndex /SelectedImageIndex for the ones you don't want.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I am getting the following error while installing the web service on windows 2008 server:
"Error 1001. Error executing command. No mapping between account names and security id"
The installer works perfect on windows 2003 server. I have migrated my installer from visual studio 2005 to VS 2010.
Gurpreet
|
|
|
|
|
Is it possible to have few secure and few unsecure web methods within a webservice. If yes, how?
Gurpreet
|
|
|
|
|
Put the security within the webmethod call itself. I have a service that does that .. some methods are "public" others are only accessible by users in particular security groups.
So the secure web methods have an if around all the code that checks if the user is allowed to use it. The Webservice implements Integrated Windows Authentication so the user's identity is available and I have a procedure that decides whether a user is authorised or not.
|
|
|
|
|
Could you provide me some example / code snippet to do that.
Gurpreet
|
|
|
|
|
Well, not really because I don't know how you want to secure it.
In my webmethods I have eg
if (isUserAuthorised(this.User.Identity.Name))
{
} else
{
}
The isUserAuthorised method takes a string that is the user name and you can then do whatever you want to determine if they are infact allowed access. It depends on how you secure things. If you use AD groups then check whether the user is in the appropriate group (google for DirectoryEntry - there should be loads of examples out there and you'd be looking for something with objGroup.Invoke("IsMember" ...) I can't remember the exact syntax). If you have some database that says whether they're allowed in then call a stored procedure.
|
|
|
|
|
|
Redesign your data, lesson 101 of normalised data is that you only store information 1 time table 4 should have BookID, AuthorID and PubID not the information.
BTW I hope that is not the name of your table.
If you want to learn about this try and get hold of microsoft Pub demo database, it deals with this exact industry.
Also please read the guidelines for posting.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
oops i am sorry........thanks for the reply
|
|
|
|
|
This is the wrong forum.
Remove this message from here and post it in the "General database" forum - this will help you in getting a better response.
My signature "sucks" today
|
|
|
|
|
Hi ever1,
I have listBox and via coding add sth to it. I would like after I add item it select.
I eana this approach for delete and undo an item from list box.
string[] Field = new string[9];
private string SaveDataBeforDel(string Fr_Name, string Sr_Name, string St_Id, double Lb_Mark, double Ass1, double Ass2, double Fnl, double TotalMark, string Grade)
{
Field[0] = Fr_Name;
Field[1] = Sr_Name;
Field[2] = St_Id;
Field[3] = Convert.ToString(Lb_Mark);
Field[4] = Convert.ToString(Ass1);
Field[5] = Convert.ToString(Ass2);
Field[6] = Convert.ToString(Fnl);
Field[7] = Convert.ToString(TotalMark);
Field[8] = Grade;
CleabTxtBox();
return string.Empty;
}
private void LstBox_SelectedIndexChanged_1(object sender, EventArgs e)
{
if (LstBox.SelectedIndex != -1)
{
ITECH3219Student s = (ITECH3219Student)LstBox.SelectedItem;
Assigningdata_Totextbox(s.Fr_name.ToString(), s.Sr_Name.ToString(), s.St_Id.ToString(), s.Lb_Mark, s.Ass1, s.Ass2, s.Fnl, s.TotalMarkCalculation(),s.Grade.ToString());
}
}
private void Btn_Del_Click(object sender, EventArgs e)
{
Btn_Del.Enabled = false;
Btn_undo.Enabled = true;
SaveDataBeforDel(Txt_name.Text, Txt_surname.Text, Txt_Id.Text,Convert.ToDouble(Txt_lbmark.Text), Convert.ToDouble(Txt_ass1.Text), Convert.ToDouble(Txt_ass2.Text), Convert.ToDouble(Txt_final.Text),Convert.ToDouble(Txt_total.Text), Txt_grade.Text);
LstBox.Items.RemoveAt(LstBox.SelectedIndex);
}
private void Btn_undo_Click(object sender, EventArgs e)
{
Btn_Del.Enabled = true;
Btn_undo.Enabled = false;
Student_Manipulation s = new Student_Manipulation();
LstBox.Items.Add(s.AddStudent_Tolist(Field[0], Field[1], Field[2]));
Txt_lbmark.Text = Field[3];
Txt_ass1.Text = Field[4];
Txt_ass2.Text = Field[5];
Txt_final.Text = Field[6];
Txt_total.Text = Field[7];
Txt_grade.Text = Field[8];
ITECH3219Student s1 = (ITECH3219Student)LstBox.SelectedItem;
Assigningdata_Totextbox(Field[0], Field[1], Field[2], Convert.ToDouble(Field[3]), Convert.ToDouble(Field[4]), Convert.ToDouble(Field[5]), Convert.ToDouble(Field[6]), Convert.ToDouble(Field[7]), Field[8]);
Do u have any idea how can I remove an item from list box. then undo that. aftyer undo that item select.
thx in advance
|
|
|
|
|
Hello,
I am using an .exe file at my client but it gives me the error "The application failed to initialize properly(0xc0000135).Click on OK to terminate the aplication".
Earlier I used to use the same .exe file which is made in the debug folder of project for other clients but I didnt face this issue.Can you please tell what must be the problem. The OS is Windows 2000 for client and I am using Windows XP.
Pritha
|
|
|
|
|
You probably need to install the .Net Framework on that computer. I think the highest version of the .Net Framework that will work on Windows 2000 is 2.0. By the way, Google is your friend.
|
|
|
|
|
The application developer used the .Net Framework, just install the framework and Re-run the application
Remember to Reboot
HAPPY WORKING
|
|
|
|
|
Hello,
Thanks for your replies.
But I have executed .exe on the PCs which do not have .Net Framework.
Are you sure that I need to load .Net Framework
Pritha
|
|
|
|
|
|