I have compilation error at the same set of codes.
At Line 4: It says that Error 38 type 'void' cannot be converted into type
At Line 5: It says that Error 39 'Length' is not defined
I think we need to post here the other supported codes:
The scenario is: I converted a VB6 proj to VB.NET2005 using upgrade wizard then paste all controls to C#.NET2005. I've noticed that all of my array of OptionButton was converted to RadioButton with renamed into _VB6ControlName_0...._1..._2..._3 and not array of controls anymore.
.NET2005 was automatically created a component to support that functionality but using the MS VB Compatibility. I don't want to use that, therefore I need to create on my own.
private System.Collections.ArrayList tempArray; private Button[] cmdShori; private RadioButton[] optModeKbn; private RadioButton[] optInputKbn; private void GetControlArray(Control ctl, string strName, String type) { int iIndex = 0; foreach (Control control in ctl.Controls) { if (control.Name.IndexOf(strName) >= 0) { if (control.Name.IndexOf("_") >= 0) { if (IsNumeric(control.Name.Substring(control.Name.LastIndexOf('_') + 1))) { iIndex = System.Convert.ToInt32(control.Name.Substring(control.Name.LastIndexOf('_') + 1)); if (control.GetType().ToString() == type) { //search for "_" to determine if it was an array of radiobuttons if (control.Name.IndexOf("_") >= 0) { AddToList(ref tempArray, iIndex); tempArray[iIndex] = control; } } } } } if (control.HasChildren) { GetControlArray(control, strName, type); } } }
//gets the array of RadioButton controls public void GetControlArray(ref RadioButton[] btArray, string ArrayName) { if (btArray == null) { int i = 0; tempArray = new System.Collections.ArrayList(); GetControlArray(this, ArrayName, "System.Windows.Forms.RadioButton"); btArray = new RadioButton[tempArray.Count]; foreach (RadioButton rb in tempArray) { btArray[i++] = rb; } } }
public int GetIndex(string Name) { int Index = 0; if (Name.IndexOf("_") >= 0) { if (IsNumeric(Name.Substring(Name.LastIndexOf("_") + 1))) { Index = Convert.ToInt32(Name.Substring(Name.LastIndexOf("_") + 1)); } } return Index; }
void AddToList(ref System.Collections.ArrayList arr, int iIndex) { if (arr.Count <= iIndex) { for (int i = arr.Count; i <= iIndex; i++) { arr.Add(null); } } }
|