This is kind of a oddball problem so I will try to describe the best that I can.
I have a DataGridView
that shows a list of contracts and various pieces of information about them. There are three view modes: Contract Approval, Pre-Production, and Production. Each mode has it's own set of columns that need to be displayed.
What I have been doing is I have three radio buttons one for each contract style. all of them fire their check changed on this function
private void rbContracts_CheckedChanged(object sender, EventArgs e)
{
dgvContracts.Columns.Clear();
if (((RadioButton)sender).Checked == true)
{
if (sender == rbPreProduction)
{
dgvContracts.Columns.AddRange(searchSettings.GetPreProductionColumns());
this.contractsBindingSource.DataMember = "Preproduction";
this.preproductionTableAdapter.Fill(this.searchDialogDataSet.Preproduction);
}
else if (sender == rbProduction)
{
dgvContracts.Columns.AddRange(searchSettings.GetProductionColumns());
this.contractsBindingSource.DataMember = "Production";
this.productionTableAdapter.Fill(this.searchDialogDataSet.Production);
}
else if (sender == rbContracts)
{
dgvContracts.Columns.AddRange(searchSettings.GetContractsColumns());
this.contractsBindingSource.DataMember = "Contracts";
this.contractsTableAdapter.Fill(this.searchDialogDataSet.Contracts);
}
}
}
Here is the GetxxxColumns function
public DataGridViewColumn[] GetPreProductionColumns()
{
this.dgvTxtPreAccount.Visible = DgvTxtPreAccountVisable;
this.dgvTxtPreImpromedAccNum.Visible = DgvTxtPreImpromedAccNumVisable;
this.dgvTxtPreCreateDate.Visible = DgvTxtPreCreateDateVisable;
this.dgvTxtPreCurrentSoftware.Visible = DgvTxtPreCurrentSoftwareVisable;
this.dgvTxtPreConversionRequired.Visible = DgvTxtPreConversionRequiredVisable;
this.dgvTxtPreConversionLevel.Visible = DgvTxtPreConversionLevelVisable;
this.dgvTxtPreProgrammer.Visible = DgvTxtPreProgrammerVisable;
this.dgvCbxPreEdge.Visible = DgvCbxPreEdgeVisable;
this.dgvCbxPreEducationRequired.Visible = DgvCbxPreEducationRequiredVisable;
this.dgvTxtPreTargetMonth.Visible = DgvTxtPreTargetMonthVisable;
this.dgvCbxPreEdgeDatesDate.Visible = DgvCbxPreEdgeDatesDateVisable;
this.dgvTxtPreStartDate.Visible = DgvTxtPreStartDateVisable;
this.dgvTxtPreUserName.Visible = DgvTxtPreUserNameVisable;
this.dgvCbxPreProductionId.Visible = DgvCbxPreProductionIdVisable;
return new System.Windows.Forms.DataGridViewColumn[] {
this.dgvTxtPreAccount,
this.dgvTxtPreImpromedAccNum,
this.dgvTxtPreCreateDate,
this.dgvTxtPreCurrentSoftware,
this.dgvTxtPreConversionRequired,
this.dgvTxtPreConversionLevel,
this.dgvTxtPreProgrammer,
this.dgvCbxPreEdge,
this.dgvCbxPreEducationRequired,
this.dgvTxtPreTargetMonth,
this.dgvCbxPreEdgeDatesDate,
this.dgvTxtPreStartDate,
this.dgvTxtPreUserName,
this.dgvCbxPreProductionId,
this.dgvTxtCmnHold,
this.dgvTxtCmnConcern,
this.dgvTxtCmnAccuracyStatus,
this.dgvTxtCmnEconomicStatus,
this.dgvTxtCmnSoftwareStatus,
this.dgvTxtCmnServiceStatus,
this.dgvTxtCmnHardwareStatus,
this.dgvTxtCmnAncillaryStatus,
this.dgvTxtCmnFlowStatus,
this.dgvTxtCmnImpromedAccountNum,
this.dgvTxtCmnOpportunityId};
}
public DataGridViewColumn[] GetProductionColumns()
{
this.dgvcTxtProAccount.Visible = DgvTxtProAccountVisable;
this.dgvTxtProImpromedAccNum.Visible = DgvTxtProImpromedAccNumVisable;
this.dgvTxtProCreateDate.Visible = DgvTxtProCreateDateVisable;
this.dgvTxtProConvRequired.Visible = DgvTxtProConvRequiredVisable;
this.dgvTxtProEdgeRequired.Visible = DgvTxtProEdgeRequiredVisable;
this.dgvTxtProStartDate.Visible = DgvTxtProStartDateVisable;
this.dgvTxtProHardwareRequired.Visible = DgvTxtProHardwareReqiredVisable;
this.dgvTxtProStandardDate.Visible = DgvTxtProStandardDateVisable;
this.dgvTxtProSystemScheduleDate.Visible = DgvTxtProSystemScheduleDateVisable;
this.dgvTxtProHwSystemCompleteDate.Visible = DgvTxtProHwSystemCompleteDateVisable;
this.dgvTxtProHardwareTechnician.Visible = DgvTxtProHardwareTechnicianVisable;
return new System.Windows.Forms.DataGridViewColumn[] {
this.dgvcTxtProAccount,
this.dgvTxtProImpromedAccNum,
this.dgvTxtProCreateDate,
this.dgvTxtProConvRequired,
this.dgvTxtProEdgeRequired,
this.dgvTxtProStartDate,
this.dgvTxtProHardwareRequired,
this.dgvTxtProStandardDate,
this.dgvTxtProSystemScheduleDate,
this.dgvTxtProHwSystemCompleteDate,
this.dgvTxtProHardwareTechnician,
this.dgvTxtCmnHold,
this.dgvTxtCmnConcern,
this.dgvTxtCmnAccuracyStatus,
this.dgvTxtCmnEconomicStatus,
this.dgvTxtCmnSoftwareStatus,
this.dgvTxtCmnServiceStatus,
this.dgvTxtCmnHardwareStatus,
this.dgvTxtCmnAncillaryStatus,
this.dgvTxtCmnFlowStatus,
this.dgvTxtCmnImpromedAccountNum,
this.dgvTxtCmnOpportunityId};
}
public DataGridViewColumn[] GetContractsColumns()
{
this.dgvTxtConAccount.Visible = this.DgvTxtConAccountVisable;
this.dgvTxtConAccuracyStatus.Visible = this.DgvTxtConAccuracyStatusVisable;
this.dgvTxtConCreateDate.Visible = this.DgvTxtConCreateDateVisable;
this.dgvTxtConEconomicStatus.Visible = this.DgvTxtConEconomicStatusVisable;
this.dgvTxtConHardwareStatus.Visible = this.DgvTxtConHardwareStatusVisable;
this.dgvTxtConImpromedAccNum.Visible = this.DgvTxtConImpromedAccNumVisable;
this.dgvTxtConServiceStatus.Visible = this.DgvTxtConServiceStatusVisable;
this.dgvTxtConSoftwareStatus.Visible = this.DgvTxtConSoftwareStatusVisable;
this.dgvCbxConPreProductionId.Visible = this.DgvCbxConPreProductionIdVisable;
this.dgvCbxConProductionId.Visible = this.DgvCbxConProductionVisable;
return new System.Windows.Forms.DataGridViewColumn[] {
this.dgvTxtConAccount,
this.dgvTxtConImpromedAccNum,
this.dgvTxtConCreateDate,
this.dgvTxtConAccuracyStatus,
this.dgvTxtConEconomicStatus,
this.dgvTxtConSoftwareStatus,
this.dgvTxtConServiceStatus,
this.dgvTxtConHardwareStatus,
this.dgvCbxConPreProductionId,
this.dgvCbxConProductionId,
this.dgvTxtCmnHold,
this.dgvTxtCmnConcern,
this.dgvTxtCmnAccuracyStatus,
this.dgvTxtCmnEconomicStatus,
this.dgvTxtCmnSoftwareStatus,
this.dgvTxtCmnServiceStatus,
this.dgvTxtCmnHardwareStatus,
this.dgvTxtCmnAncillaryStatus,
this.dgvTxtCmnFlowStatus,
this.dgvTxtCmnImpromedAccountNum,
this.dgvTxtCmnOpportunityId};
}
The issue is when I check a button the first time, everything shows up ok. I choose another view, everything is ok. But when I click on the first view the columns are out of order (it is like they are in reverse order but it is not exactly the same). this happens only to the first page you click on, the other two are fine. You can click off and click back on as many times as you want after those initial steps, The first list you selected at the start will be out of order the other two will be correct.
Any ideas on what could be causing this?
EDIT--
Things I have found so far:
ColumnDisplayIndexChanged
fires many many times (over 200 times) when I view the first selection a second time. if the function does nothing it still loads the page, if i put a dialog box to show it fired (it was a lot of clicks) eventually i either get a big red X in the data grid view area or it loads fine (depending on the page, I get a X for pre-production but the other two loads fine (the message box still shows up hundreds of times) when you select them first)