|
-
October 26th, 2011, 03:17 PM
#1
[RESOLVED] TabControl selectedIndex 1 with colorDialog
weird bug - not sure what I am doing wrong
dragged a ColorDialog from the toolbox to the form...
I have a TabControl for my form. Tab 0 and Tab 1, as long as I am on selectIndex 0, if I open my colorDialog it works fine. If I switch to selectedIndex 1 and open my colorDialog, program crashes. I've done this too..
Code:
private void buttonSetColor_Click(object sender, EventArgs e)
{
tabControl.SelectedIndex = 0;
colorDialog.ShowDialog();
}
works great.. but for this situation I don't want to have to make it switch tabs just because I want to bring up the colorDialog. This code > if selectedIndex 1 - crashes my form
Code:
private void buttonSetColor_Click(object sender, EventArgs e)
{
colorDialog.ShowDialog();
}
weird?!?
-
October 27th, 2011, 01:42 AM
#2
Re: TabControl selectedIndex 1 with colorDialog
I just tried with the following code by adding tabcontrol and a color dialog with VisualStudio-2005 and .Net Framework 2.0
Irrespective of the selected index of the tabcontrol( 0/1 ) the color dialog opens fine.
Can you please let us know the visual studio and framework version which you are using ?
Thanks
Murali
-
October 27th, 2011, 07:58 AM
#3
Re: TabControl selectedIndex 1 with colorDialog
Check out what the control the colorDialog is a child of. Is it the main form? Is it the tabcontrol? Is it a page or a panel inside the tab control?
-
October 27th, 2011, 02:50 PM
#4
Re: TabControl selectedIndex 1 with colorDialog
@ rockmurali - im using 4.0 Framework
@ arjay - thanks you gave me some ideas: but I don;t know how to check the control for a child control so I just dragged another ColorDialog directly onto Tab 1, and named it colorDialogTab1 - and this still does not work. Additionally I've tried dragging the colorDialog directly onto the main form.
I am not doing anything but ShowDialog(), so there are no hidden dependencies... I will open a new project and test this again.
-
October 27th, 2011, 03:05 PM
#5
Re: TabControl selectedIndex 1 with colorDialog
@ rockmurali, yeh started new project used many different combinations of adding the colorDialog to the form and it all works. There must be something deep in the form that is causing this. Additionally when I switch tabs some of my labels are black transparent boxes, meaning where that label is located; I can see the previous Tab behind it. This goes away when I move the form.
I've decided to create a new project, and just port most of the code over while 1st creating the structure of the form environment. I hope this solves it.
-
October 27th, 2011, 05:53 PM
#6
Re: TabControl selectedIndex 1 with colorDialog
 Originally Posted by bixel
@ arjay - thanks you gave me some ideas: but I don;t know how to check the control for a child control so I just dragged another ColorDialog directly onto Tab 1, and named it colorDialogTab1 - and this still does not work.
You can open the designer file. Right click on the myform.designer.cs and choose view code. To find what the colorDialog1 control's parent, just search for it's name in the file and look for the like that says .AddControl( colorDialog1 ).
I might be off a bit on the naming, but you get the idea.
-
November 22nd, 2011, 12:03 PM
#7
Re: TabControl selectedIndex 1 with colorDialog
Even creating a new project did not work. I tested with a simple project and works fine.. However as soon as I add more Dialogs to the main Form, colorDialog get hidden somewhere when I try to fire it.
I've added a TimerControl, ContextMenu, MenuStrip, Tooltip, and another ContextMenu as my added components.
I've completely got rid of TabControl by this point. And my set color button is on the main form. But when I click it the form flashes like its opening colorDialog, but there is nothing there. I have to stop debugging to close the main Form.
I've also tried this
Code:
foreach (Control c in this.Controls)
{
if (c.Name == "colorDialog")
{
c.Show();
c.BringToFront();
}
}
but that doesn't work since colorDialog is not a control....
not sure what to do here.
-
November 23rd, 2011, 08:16 PM
#8
Re: TabControl selectedIndex 1 with colorDialog
Did you try what I suggested in post #6?
-
November 24th, 2011, 01:28 PM
#9
Re: TabControl selectedIndex 1 with colorDialog [SOLVED]
Arjay: yes checked and double checked
I found the problem!!! I had a Picture box with a custom Paint command. It seemed it was try to paint waaay too many times. So I slowed it down with a Control Timer
Code:
void FormMain_Load(object sender, EventArgs e)
{
controlTimer.Tick += new EventHandler(controlTimer_Tick);
controlTimer.Enabled = true;
controlTimer.Interval = 17; //about 60 FPS
....
other code
}
void controlTimer_Tick(object sender, EventArgs e)
{
frameCount = ++frameCount % 6;
pictureBoxNPCSprite_Paint();
}
This solved it perfectly!
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
|