|
I have opened a Excel spreadsheet with c# by using the Excel.Application class. After I have closed the excel file in windows by clicking on the X in the upper right hand corner, the process EXCEL.EXE stil remains.???
|
|
|
|
|
Did you click on X of the main form or just close a document ?
<< >>
|
|
|
|
|
Yes, basically the user does...
|
|
|
|
|
Sorry! I've clicked on X of the main form.
|
|
|
|
|
lol, OK ... Happy Coding
<< >>
|
|
|
|
|
Sorry! I've clicked on X of the main form.
|
|
|
|
|
Hello,
Please try to do this in Closing event of the main form.
if(excelApplication != null && excelApplication.Workbooks.Count > 0)<br />
{<br />
foreach(Workbook wb in excelApplication.Workbooks)<br />
{<br />
wb.Close(false,Type.Missing,Type.Missing); <br />
}<br />
excelApplication.Quit();<br />
excelApplication.Visible = false;<br />
}
where excelApplication is an Excel.ApplicationClass object.
HTH. Cheers
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
Hi everyone, i have a problem indatagrid.Here is the code below and my problem is i want to retrieve the data from database on to the datagrid based on the selection of dropdowlist. After me selecting the dropdownlist option, datagrid is not displayed. Please help me where am i doing wrong.
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
connectdb();
Cmd.CommandText = "Select * from emp order by Empno where Dept='" + DropDownList1.SelectedItem.Value.ToString() + "'";
da.SelectCommand = Cmd;
da.Fill(ds,"Emp");
DataGrid1.DataSource = ds;
DataGrid1.DataMember = "Emp";
DataGrid1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Con.Close();
}
thanx in advance
yamini
|
|
|
|
|
try this
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
SqlConnection con = new SqlConnection("ur connection string");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("Select * from emp order by Empno where Dept='" + DropDownList1.Value.ToString() + "'",SqlConnection);
//connectdb();
//Cmd.CommandText =
//da.SelectCommand = Cmd;
DataSet ds = new DataSet();
da.Fill(ds,"Emp");
DataGrid1.DataSource = ds.Tables["emp"];
//DataGrid1.DataMember = "Emp";
DataGrid1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
Con.Close();
}
|
|
|
|
|
Alright, I'm trying to integerate an IR remote control into one of my apps. I used Spy++ to try to figure out what messages were being sent to the app. The WM_APPCOMMAND message is begin sent. But this message is being sent for the every media key. i read somewhere that you ahve to use GET_APPCOMMAND_LPARAM(lparam) to get the unique media key but i dont know how to implement this in C#. I am currently overloading the WndProc(ref Message m) even and attempting to do something when the message == WM_APPCOMMAND...but again i dont know how to differentiate between the different WM_APPCOMMAND's.... Play...Stop....Next Track....Previous Track....are all the same message...help guys.
-- modified at 0:30 Thursday 22nd December, 2005
|
|
|
|
|
The Message[^] structure that gets passed to the WndProc method has LParam and WParam properties. You need to look into how GET_APPCOMMAND_LPARAM(lparam) is implemented to get the value out of the LParam property.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
figured it out, there is a lparam property in the message structure that i have to interperet AFTER i catch on the wparam property of app_command....a long int get returned. simple switch statement and i got it all working. thanks for your help
|
|
|
|
|
hi
Does anyone here can give me good sites or book recommendations for the customs controls in C#
I want to create custom control for the radio button in the datagrid where I want give the user only one option to select the items from the database
Is custom control for radiobuttonlist in datagrid is possible or not??
thanks in advance
kal13na13
|
|
|
|
|
Hello
I think it's impossible and you should choose your field as boolean and datagrid shows that as CheckBox.
for this in Datagrid TableStyle you should define DataGridBoolColumn.
for additional goto :
Styling with the DataGridColumnStyle, Part 2
Is it usefull ?
|
|
|
|
|
Hi,
I am able to draw line between two points during MouseDown and MouseUp events...
But i ve two problems over it...
1.when i handle the mouse events,the lines arenot drwan immediately...It displays the line only after i chang the focus and return back to the form..
2.The line which i ve drawn should vanish when i draw another line...
How can i do these..
Am new to this graphics section...So kindly help me...
Thanx
|
|
|
|
|
Do you draw your line in OnPaint ? That's the only place to do it. Call Invalidate() in your mouseup to trigger OnPaint.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ya i did...
Here's the code...
<br />
public void OnPaint(object sender,PaintEventArgs e)<br />
{<br />
Graphics g=e.Graphics; <br />
Pen pen=new Pen(Color.Magenta);<br />
Point p1=new Point(index1,index2);<br />
Point p2=new Point(index3,index4);<br />
g.DrawLine(pen,p1,p2); <br />
} <br />
<br />
public void mouseUp(object sender,MouseEventArgs e)<br />
{<br />
index3=e.X;index4=e.Y; <br />
this.Paint+=new PaintEventHandler(this.OnPaint); <br />
Invalidate();<br />
}<br />
public void mouseDown(object sender,MouseEventArgs e)<br />
{<br />
index1=e.X;index2=e.Y; <br />
}<br />
Kindly help me...
Its very urgent
Thanx
|
|
|
|
|
fyi. i already replied to your other post.
|
|
|
|
|
ya ,i got it....
Thank u.......
|
|
|
|
|
Mahi.Ragava wrote: this.Paint+=new PaintEventHandler(this.OnPaint);
This is bizarre, and totally unnecessary.
This will draw the last line that you drew, the only thing I would change is to set index3 and index4 in mouseDown to be the same as index1 and index2, and then call Invalidate(), and I would handle mousemove, setting index3 and index4 as you go, calling invalidate again ( when the mouse is down ).
Also, I would replace index1-4 with two Point variables.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I am writing some code (for fun) that will display the mouse coordinates in real time on a WinForm. The "e.X, e.Y" coordinate text is displayed next to the position of the cursor. Problem is, every time I move the mouse the graph that I've drawn to "run" the coordinates over
keeps getting re-drawn (flicker?) until I stop moving the mouse-- and then the coordinates are displayed over the graph I've drawn. Is there any way to fix this?
ps- many people have very helpful to my questions --> I am very grateful.
////////////////////////////////////////////////////////////
Here are the relevant code fragments....1)Paint, 2)MouseMove, 3)override OnPaint
///////////////////////////////////////////////////////////
void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawRectangle(graphPen, xIndent, yIndent, 400,400);
g.FillRectangle(graphBrush, xIndent, yIndent, 400, 400);
g.DrawLine(graphPen, xIndent + 200, yIndent, xIndent + 200, yIndent + 400);
g.DrawLine(graphPen, xIndent, yIndent + 200, xIndent + 400, yIndent + 200);
DrawGraphLines(g);
DrawXYAxes(g);
if(m_bFlag1)
DrawComplexLineA(g);
if(m_bFlag2)
DrawComplexLineB(g);
if(m_bAddFlag)
DrawComplexAdd(g);
}
///////////////////////////////////////////////////////////////////////////
private Point mousePoints;
protected override void OnMouseMove(MouseEventArgs e)
{
// TODO: Add Form1.OnMouseMove implementation
mousePoints = new Point(e.X,e.Y);
Invalidate();
base.OnMouseMove (e);
}
////////////////////////////////////////////////////////////////////////////
protected override void OnPaint(PaintEventArgs e)
{
// TODO: Add Form1.OnPaint implementation
base.OnPaint (e);
Point screen = PointToScreen(mousePoints);
string location = screen.ToString();
e.Graphics.DrawString("[Screen: " + location + "]",
new Font("Arial",8),
SystemBrushes.ControlText,
(PointF)mousePoints);
}
/////////////////////////////////////////////////////////
|
|
|
|
|
Turn on double buffering:
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true);
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian,
Thanks-- In which/where (method?) do I "turn on double buffering"?
what's "this."? - An instantiated "what"?
I'm a bit behind the learning curve here but very appreciative of your response-- thanks again....
|
|
|
|
|
sorry for the interruption...
just call the method(what christian gave you) on the constructor of your control.
Hope that helps!
|
|
|
|
|
this means the class that the code is written in. You don't need it, actually.
Christian Graus - Microsoft MVP - C++
|
|
|
|