In JobHead form, I added a new baqComboBox, which is bound to my JobHead.NumBCclient_c field.
I have used the ExtendedProperties of the field to set it’s readonly property depending of the part being produced.
private void SetClientBCEnabled( bool val)
{
// Begin Wizard Added EpiDataView Initialization
edvJobHead = ((EpiDataView)(this.oTrans.EpiDataViews["JobHead"]));
// End Wizard Added EpiDataView Initialization
// Begin Wizard Added Conditional Block
if (edvJobHead.dataView.Table.Columns.Contains("NumBCclient_c"))
{
// Begin Wizard Added ExtendedProperty Settings: edvJobHead-NumBCclient_c
edvJobHead.dataView.Table.Columns["NumBCclient_c"].ExtendedProperties["ReadOnly"] = !val;
// End Wizard Added ExtendedProperty Settings: edvJobHead-NumBCclient_c
}
// End Wizard Added Conditional Block
}
This was added using the wizard originally, and modified to be changed depending of the partnum.
Running the debugger, I can see the value being modified to false, for the readonly of the field, but the combo is staying grey, readonly = true. The object readonly is as well true…???
I have tried with all the combos, and they all behave the same. As soon as I added a text box, the text box behaves as expected, being normal, if readonly is active, it is grey, if not is it available to edit.
My question: Is this a bug? Not being able to make a combo box readonly?
I basically want the new combo to look the same as other fields, being greyed out, when I am readonly to true, and available to dropdown, and white if readonly is false.
Maybe there is another way? but was trying the famous @epimagic@ as we are supposed to do…
Try adding the two usings below and also putting the code into your InitializeCustomCode event
//Set a drop down menu so a user cannot enter their own values and must pick from the list
//put this in the InitializeCustomCode method
//I think you also need these two assemblies referenced
//using Infragistics.Win;
//using Infragistics.Win.UltraWinGrid;
cmbMyCustomDropdown.DropDownStyle = Infragistics.Win.UltraWinGrid.UltraComboStyle.DropDown;
I recommend you try the standard functions of the system, find the menu system setup> System maintenance> Extended Properties, Enter the JobHead_UD in DataSetTable ID column, then select the NumBCclient_c field you want set as Readonly, and switch to the Column sheet, find the check box “Read Only” and tick it and Save.
I used base form, and added a baqCombo, a text box and a UltraCombo, all bound the the udfield. I added the readonly code with the wizard, set it to RO = true in initialize code.
I added two buttons, one to set RO to true (but1) and the other to set it to false (but2).
Code snippet
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
SetExtendedProperties(false);
this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
this.epiButtonC2.Click += new System.EventHandler(this.epiButtonC2_Click);
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
this.epiButtonC2.Click -= new System.EventHandler(this.epiButtonC2_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void SetExtendedProperties(bool val)
{
// Begin Wizard Added EpiDataView Initialization
EpiDataView edvJobHead = ((EpiDataView)(this.oTrans.EpiDataViews["JobHead"]));
// End Wizard Added EpiDataView Initialization
// Begin Wizard Added Conditional Block
if (edvJobHead.dataView.Table.Columns.Contains("NumBCclient_c"))
{
// Begin Wizard Added ExtendedProperty Settings: edvJobHead-NumBCclient_c
edvJobHead.dataView.Table.Columns["NumBCclient_c"].ExtendedProperties["ReadOnly"] = val;
// End Wizard Added ExtendedProperty Settings: edvJobHead-NumBCclient_c
}
// End Wizard Added Conditional Block
}
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
SetExtendedProperties(true);
}
private void epiButtonC2_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
SetExtendedProperties(false);
}
I opened the job, removed the Release and Engineered flags , so they are false. saved and closed the form.
Opening the form, the field is grey. (normal there is no records yet.) and the default is set to true in initialize…
Opening the job, I press the but2, to change the readonly but all stays grey.
BUT
I change the initialize value to readonly = false.
I re-open the form, load the job, and voilà… the objects are available to use…
Pressing but1 to set to false has also no impact to the readonly…same as previous test…
So I wonder if a combo box , in this form, something is not allowing the readonly state to change … after the form is loaded…