|
-
Sep 22nd, 2010, 07:19 AM
#1
Thread Starter
Frenzied Member
Excel VSTO Dialog Form
I have the c# code below for a VSTO excel app im working on however for somereason clicking ok on the dialog form (which should close the form) causes the dialog to re-appear. This happens twice.
I am concerned I am not accessing the value on the form correctly although I cant find how to set its parent to being the Excel workbook.
Code:
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
frmPromptForConnection objfrmPromptForConnection;
objfrmPromptForConnection = new frmPromptForConnection();
objfrmPromptForConnection.Parent = this;
DAL.Connection = "Production";
objfrmPromptForConnection.ShowDialog();
if (objfrmPromptForConnection.ShowDialog() == DialogResult.OK)
{
DAL.Connection = objfrmPromptForConnection.Connection;
}
}
else
{
DAL.Connection = "Production";
}
}
-
Sep 22nd, 2010, 07:27 AM
#2
Thread Starter
Frenzied Member
Re: Excel VSTO Dialog Form
I took out the first
Code:
objfrmPromptForConnection.ShowDialog();
This seems to work for preventing the show twice but not the retreiving value problem, also the cursor is always set as the hourglass when on the dialog, can this be changed/ should it have to be?
-
Sep 22nd, 2010, 08:37 AM
#3
Re: Excel VSTO Dialog Form
I dont know C# but reading a little about it made me ask you this question... 
Also I have removed one extra bracket and added the 'dispose' line. Hope it is done that ways?
Code:
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
frmPromptForConnection objfrmPromptForConnection;
objfrmPromptForConnection = new frmPromptForConnection();
objfrmPromptForConnection.Parent = this;
DAL.Connection = "Production";
if (objfrmPromptForConnection.ShowDialog() == DialogResult.OK)
{
// What does this give you
MessageBox.Show(objfrmPromptForConnection.Connection);
DAL.Connection = objfrmPromptForConnection.Connection;
}
Else
{
DAL.Connection = "Production";
}
objfrmPromptForConnection.Dispose();
}
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Sep 22nd, 2010, 09:12 AM
#4
Thread Starter
Frenzied Member
Re: Excel VSTO Dialog Form
Well as suspected, the msgbox wasnt getting hit because the dialog result never got set to ok.
I thought by setting the forms OK property to the OK button would have been enough. I had to add
Code:
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
// Close();
}
For it to work. The workbook code could then access the forms properties without having to be set as parent.
So my final problem is why is the cursor set to Hourglass when the morm appears?
-
Sep 22nd, 2010, 09:25 AM
#5
Re: Excel VSTO Dialog Form
So my final problem is why is the cursor set to Hourglass when the morm appears?
Like I mentioned that I dont know C# so I googled it and got so many links that I got confused See if any of these make sense to you...
http://www.google.co.in/#hl=en&sourc...5c7405d4a7e2c8
also this
http://bytes.com/topic/c-sharp/answe...e-dialog-hangs
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Sep 22nd, 2010, 09:42 AM
#6
Thread Starter
Frenzied Member
Re: Excel VSTO Dialog Form
I think there is somekind of override taking place.
If I set the form cursor to arrow then i get the arrow on most of the form now except for if I hover over a user control. I have tried setting the usercontrol to arrow but this doesnt take effect.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|