|
If you talking about C# you do not need API for this, just set to false the MaximizeBox property for the Form object.
|
|
|
|
|
I've a simple function:
<code>
private void BuildTree()
{
TreeNode rootNode = new TreeNode("Root");
TreeNode node1 = new TreeNode("Child 1");
TreeNode node11 = new TreeNode("Child 11");
TreeNode node12 = new TreeNode("Child 12");
node1.Nodes.Add(node11);
node1.Nodes.Add(node12);
rootNode.Nodes.Add(node1);
TreeNode node2 = new TreeNode("Child 2");
rootNode.Nodes.Add(node2);
TreeNode node3 = new TreeNode("Child 3");
rootNode.Nodes.Add(node3);
treeView1.Nodes.Add(rootNode);
if (!rootNode.IsExpanded)
{
rootNode.Expand();
}
}
</code>
My problem is:
If I create a new Winforms application, the expand function does its work, but if the same function is written into a .dll where the treeview is on a usercontrol, expand does nothing. I mean the node doesn't expands so I have to click on '+' to do it.
I use the same function at each time.
Any guess?
Peter Kovacs
collapo
|
|
|
|
|
Just a guess but the difference may be at what point you call this function. Probably your test app already shows the treeview when calling the function while your usercontrol calls the function before the tree is visible.
I don't think it has anything to do with the user control as I already used Expand on TreeViews within user controls.
Robert
|
|
|
|
|
The treeview is shown in initializecomponents in both project, if I'm not mistaken, therefore that can not be the problem. The function is called right after Initializecomponents(), so it is called "at the same time".
But anyway thanks, I'm waiting for others.
And the winform application is not a test, but a paralell application.
Peter
|
|
|
|
|
Hi,
I am using MSACCESS database which is belonged with password. and I need to know that how do I create connection string?
Thanks in Advance
|
|
|
|
|
|
Thank you Mr. il_masacratore
|
|
|
|
|
Hi,
The following is the code i used to create, write to and save an excel file. Everything goes fine except there is a delay in releasing the object. Yes it persists till the application is closed. Sometimes i'm able still see the excel.exe in the task manager even after the application is closed. Is there any way to overcome this.
I've added a reference to excel 11.0 com component.
private void CreateExcel()
{
Excel.Application ExcelApp = null;
Excel._Workbook ExcelWorkbook = null;
Excel._Worksheet ExcelWorkSheet = null;
string strSavePath = "";
try
{
ExcelApp = new Excel.Application();
ExcelApp.Visible = false;
ExcelWorkbook = (Excel._Workbook)(ExcelApp.Workbooks.Add(Type.Missing));
ExcelWorkSheet = (Excel._Worksheet)ExcelWorkbook.Sheets["Sheet1"];
// ExcelWorkSheet.Name = "My Sheet";
//Make sure Excel is visible and give the user control
//of Microsoft Excel's lifetime.
ExcelApp.Visible = false;
ExcelApp.UserControl = false;
/*********************/
DataSet dsData = MyDataLayer.GetDataSet("Select top(3) from XXXX");
if (dsData != null && dsData.Tables.Count > 0)
{
// the writing process
ExcelWorkSheet.Cells[iRowIndex, iColumnIndex] = data;
}
/*********************/
//ExcelWorkSheet.get_Range("A3", "F3").HorizontalAlignment =
//Excel.XlHAlign.xlHAlignCenter;
//ExcelWorkSheet.get_Range("A1", "A1").Font.Bold = true;
ExcelWorkSheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
ExcelWorkSheet.Activate();
ExcelWorkSheet.get_Range("A3", "F3").EntireColumn.AutoFit();
//ExcelWorkSheet.get_Range("E1","E1").Columns.EntireColumn.NumberFormat = "£###,###,##0.00";
strSavePath = Application.ExecutablePath.ToString();
strSavePath = strSavePath.Substring(0, strSavePath.LastIndexOf("\\"));
strSavePath = strSavePath + "\\TestExcelFile.xls";
ExcelWorkbook.SaveAs(strSavePath, Excel.XlFileFormat.xlExcel7, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// ExcelWorkbook.Close(false, strSavePath, null);
// return;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
if (ExcelWorkSheet != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkSheet);
ExcelWorkSheet = null;
}
if (ExcelWorkbook != null)
{
ExcelWorkbook.Close(false, strSavePath, null);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkbook);
ExcelWorkbook = null;
}
if (ExcelApp != null)
{
ExcelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApp);
ExcelApp = null;
}
}
finally
{
if (ExcelWorkSheet != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkSheet);
ExcelWorkSheet = null;
}
if (ExcelWorkbook != null)
{
ExcelWorkbook.Close(false, strSavePath, null);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkbook);
ExcelWorkbook = null;
}
if (ExcelApp != null)
{
ExcelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApp);
ExcelApp = null;
}
//GC.WaitForPendingFinalizers();
}
GC.Collect();
}
Thanks,
PLS
|
|
|
|
|
I have also run into this problem some time ago. The only solution (workaround) I found was to get a list of all running processes (Process.GetProcesses) before creating the Excel.Application instance and then again after the creation to fetch the corresponding process. I then killed this process after being done.
I know this is completely insane but as said I didn't find any other solution.
Robert
|
|
|
|
|
Hi All,
I am using FolderBrowserDialog in my application. FolderBrowserDialog have RootFolder Property, where it gets or sets the root folder where the browsing starts from. But we can assign only SpecialFolder to RootFolder.
Is it possible to assign user specified folders other than special folders?
Is there any other dialog where we can achieve this?
Thanks in advance.
|
|
|
|
|
The SelectedPath property is what you're looking for.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank You. Thank You. Thank You.
|
|
|
|
|
Hi!
I want to dial a number by my modem and play a voice after a person response to the call.
|
|
|
|
|
why?
Check out this thread....(not a CP thread though)
http://www.velocityreviews.com[^]
Just type dial number modem C# into google. It's quicker than posting here believe it or not.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Hi,
(thanks for all the help in the past)
I'm trying to sort a column in a DataGridView. I know it does this automatically, but I'm trying to sort the column so that the cell containing a specific text (Exception) is always at the top.
'Exception' is does not come first alphabetically in the grid.
Is there any way of getting around this?
God Bless
Deji
|
|
|
|
|
Hi,
When i tried to serialize WinForms, i got SerializationException, Though i
the attribute [Serializable()] is added .
Please help me to serialize a form object.
With Thanks,
Sakthi.
|
|
|
|
|
Hello,
You really have to provide more information.
The exception message would be of great help.
Maybe one of the public fields in your class is not serializable.
Have you looked at the articles (like this[^]) here on the forum?
Hope it helps!
-- modified at 7:31 Wednesday 1st August, 2007
Here, an article for serializing WinForms[^]
All the best,
Martin
|
|
|
|
|
You can't serialize a winform in it's entirety because several of the Form members are not serializable.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
I am at the final stage of developing an application which allow user to create a screensaver from images(gif,bmp or jpg). The images are loaded at run-time. Now how can I integrate these as embedd in the new exe ? Is there a way I can do it ?
Currently, I am loading the images from the path. The screensaver(scr) is developed by renaming the exe file to scr and moved to windows/system32 folder. This works very fine under windows vista. However, windows xp does not display any image with this implementation. Any help here ?
Thanks.
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg."
- Bjarne Stroustrup
|
|
|
|
|
Can you not just add the picture files in the resource manager (double click the Resources.resx file) and mark them as "Embedded at runtime" (Under the "Persistance" property)?
The picture files are integrated into the .exe this way and you can call the files in your code using Properties.Resources.FileName;
Mark.
|
|
|
|
|
I am adding images at run-time. So I cannot do this since it is done at compile time.
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg."
- Bjarne Stroustrup
|
|
|
|
|
Hi
I am developing an application in ASP.net 2.0 / C# / SQL server2005.The problem is that when end user clicks on download hyperlink it downloads the entire page along with the file which needs to be downloaded.This happens only in case of .HTML extension. e.g. End user wants "a.html" page which is populated on my "xyz.aspx" page.So he click on download link to download "a.html" but ends up downloading "a.html" and "xyz.aspx"(html).
Any help will be greatly appreciated.
Waiting for positive reply.
MY CODE:
DOWNLOAD FUNCTION
private void downloadFile(string sid, string fn,string foldertype)
{
//string siteId = Session["siteid"].ToString();
//string folder = Session["foldertype"].ToString();//
if (File.Exists(Server.MapPath("~/Files/" + foldertype + "/" + sid + "/" + fn)))
{
string filepath = Server.MapPath("~/Files/" + foldertype + "/" + sid + "/" + fn);
if (fn.Substring((fn.Length - 1) - 2, 3) != "pdf")
{
System.IO.Stream iStream = null;
// Buffer to read 10K bytes in chunk:
byte[] buffer = new Byte[100000];
// Length of the file:
int length;
// Total bytes to read:
long dataToRead;
// Identify the file to download including its path.
Response.Write(filepath);
// Identify the file name.
string filename = System.IO.Path.GetFileName(filepath);
try
{
// Open the file.
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.Read);
// Response .Write(iStream.
// Total bytes to read:
dataToRead = iStream.Length;
Response.Clear();
//if (fn.Substring((fn.Length - 1) - 2, 3) == "pdf")
//{
// Response.ContentType = "application/pdf";
// Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
//}
//else
//{
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
//}
// Read the bytes.
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 10000);
// Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length);
// Flush the data to the HTML output.
Response.Flush();
buffer = new Byte[10000];
dataToRead = dataToRead - length;
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
}
}
}
catch (Exception ex)
{
// Trap the error, if any.
Response.Write(ex.ToString());
}
finally
{
if (iStream != null)
{
//Close the file.
iStream.Close();
}
}
}
else
{
try
{
Response.Clear();
FileStream MyFileStream = new FileStream(filepath, FileMode.Open);
long FileSize;
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
MyFileStream.Close();
Response.ContentType = "application/pdf";//octet-stream
Response.AddHeader("content-disposition", "attachment; filename=" + fn + "");
Response.BinaryWrite(Buffer);
Response.End();
}
catch (Exception ex1)
{
// Trap the error, if any.
Response.Write(ex1.ToString());
}
}
}
else
{
//lblError.Text = "Temporary file not available";
}
}
HYPERLINK CODE:
protected void filegrid_ItemCommand(object source, DataGridCommandEventArgs e)
{
try
{
MinisiteTableAdapters.FilesTableAdapter ftl = new MinisiteTableAdapters.FilesTableAdapter();
if (e.CommandName == "Download")
{
string folder = e.Item.Cells[11].Text;
downloadFile(e.Item.Cells[7].Text, e.CommandArgument.ToString(), folder);
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
RDAAC
|
|
|
|
|
Hi, i'm developing a C# windows application, my question is i have my combobox item bind from database,but how i can change my combobox item property to read only?
i've search the combobox property but there is no read only property
Regards,
Tomi
|
|
|
|
|
Hi,
You have an property named "DropDownStyle" where you can define the style/behaviour
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Oh I see..Thank for the help
Regards,
Tomi
|
|
|
|