Click here to Skip to main content
15,885,767 members
Home / Discussions / C#
   

C#

 
Questionprevent method execution on design time using attributes Pin
Gilbert Consellado7-Nov-15 15:59
professionalGilbert Consellado7-Nov-15 15:59 
AnswerRe: prevent method execution on design time using attributes Pin
George Jonsson7-Nov-15 18:00
professionalGeorge Jonsson7-Nov-15 18:00 
AnswerRe: prevent method execution on design time using attributes Pin
Richard MacCutchan7-Nov-15 21:11
mveRichard MacCutchan7-Nov-15 21:11 
GeneralRe: prevent method execution on design time using attributes Pin
Gilbert Consellado8-Nov-15 1:33
professionalGilbert Consellado8-Nov-15 1:33 
AnswerRe: prevent method execution on design time using attributes Pin
OriginalGriff7-Nov-15 22:48
mveOriginalGriff7-Nov-15 22:48 
GeneralRe: prevent method execution on design time using attributes Pin
Gilbert Consellado8-Nov-15 1:35
professionalGilbert Consellado8-Nov-15 1:35 
GeneralRe: prevent method execution on design time using attributes Pin
OriginalGriff8-Nov-15 1:41
mveOriginalGriff8-Nov-15 1:41 
GeneralRe: prevent method execution on design time using attributes Pin
Gilbert Consellado8-Nov-15 3:31
professionalGilbert Consellado8-Nov-15 3:31 
here is the constructor of the usercontrol

C#
public ctrl_patient_information()
        {
            InitializeComponent();
            InitializeControl();
        }

        public void InitializeControl()
        {
            Patient = Patient ?? new Patient();
            PatientContact = Patient.GetPatientContact();
            PatientImage = new Patient.PatientImage(Patient);
            pictureedit_patient.Image = PatientImage.GetPatientImage();

            PopulateCombos();
            InitValidation();

            Patient.PropertyChanged += Patient_PropertyChanged;
            InitControlBinding();
        }

		private void PopulateCombos()
		{
			combo_titles.Properties.Items.AddRange(new PatientTitle[] { PatientTitle.MR, PatientTitle.MS });
			combo_titles.SelectedIndex = -1;
			combo_titles.Select();

			combo_gender.Properties.Items.AddRange(new Gender[] { Gender.Male, Gender.Female });
			combo_gender.SelectedIndex = -1;

			combo_religion.Properties.Items.AddRange(Religion.GetReligions(false));// the problem start here
			combo_religion.Leave += Religion.ValidateControlReligionItem;

			combo_marital_status.Properties.Items.AddRange(
					new MaritalStatus[]
					{
						MaritalStatus.Single,
						MaritalStatus.Married,
						MaritalStatus.Widow,
						MaritalStatus.Seperated
					}
				);
		}


when the
Religion.GetReligions(false)
been called it will try to connect to DB but the problem is the application is still in designmode, and the connectionstring for the DB is generated at runtime, so VS cant connect to db. then the Form that use the usercontrol will get an error at designtime.

C#
public static BindingList<Religion> GetReligions(bool reset)
{
    if (!reset && _bindingListItem.Count > 0) return _bindingListItem;
    DisableRaiseChangedEvent();
    _bindingListItem.Clear();
    _bindingListItemPointer.Clear();

    var ms = new MySQLSelect("SELECT * FROM `tbl_religion` WHERE `tracked_id` = @tid");
    ms.AddParamWithValue("tid", HIMSHelper.TrackedID);
    foreach (var item in ms.DataReader())
    {
        var r = new Religion()
        {
            ID = item[0].ToInt(),
            ReligionName = item[2].ToString()
        };
        _bindingListItem.Add(r);
        _bindingListItemPointer.Add(r.ID, r);
    }
    EnableRaiseChangedEvent();
    return _bindingListItem;
}


for now i have a temporary workaround, just to make it work but still looking for the best solution, the only solution i can think is to create an attribute but as for now i dont have experience creating attribute and i am running out of time. Frown | :(
GeneralRe: prevent method execution on design time using attributes Pin
Gilbert Consellado8-Nov-15 3:37
professionalGilbert Consellado8-Nov-15 3:37 
GeneralRe: prevent method execution on design time using attributes Pin
OriginalGriff8-Nov-15 4:03
mveOriginalGriff8-Nov-15 4:03 
GeneralRe: prevent method execution on design time using attributes Pin
Gilbert Consellado8-Nov-15 14:38
professionalGilbert Consellado8-Nov-15 14:38 
AnswerRe: prevent method execution on design time using attributes Pin
Nathan Minier9-Nov-15 3:18
professionalNathan Minier9-Nov-15 3:18 
Questiongdi+ shape is not a reference object in Arraylist? Pin
smallkubi7-Nov-15 5:47
smallkubi7-Nov-15 5:47 
AnswerRe: gdi+ shape is not a reference object in Arraylist? Pin
Richard MacCutchan7-Nov-15 6:14
mveRichard MacCutchan7-Nov-15 6:14 
GeneralRe: gdi+ shape is not a reference object in Arraylist? Pin
smallkubi7-Nov-15 14:01
smallkubi7-Nov-15 14:01 
GeneralRe: gdi+ shape is not a reference object in Arraylist? Pin
Richard MacCutchan7-Nov-15 21:07
mveRichard MacCutchan7-Nov-15 21:07 
AnswerRe: gdi+ shape is not a reference object in Arraylist? Pin
George Jonsson7-Nov-15 17:40
professionalGeorge Jonsson7-Nov-15 17:40 
GeneralRe: gdi+ shape is not a reference object in Arraylist? Pin
smallkubi7-Nov-15 22:06
smallkubi7-Nov-15 22:06 
GeneralRe: gdi+ shape is not a reference object in Arraylist? Pin
George Jonsson7-Nov-15 22:41
professionalGeorge Jonsson7-Nov-15 22:41 
Questioncontrol of child form when using showDialog() Pin
randor6-Nov-15 13:47
randor6-Nov-15 13:47 
AnswerRe: control of child form when using showDialog() Pin
Richard Andrew x646-Nov-15 14:30
professionalRichard Andrew x646-Nov-15 14:30 
GeneralRe: control of child form when using showDialog() Pin
randor7-Nov-15 11:46
randor7-Nov-15 11:46 
GeneralRe: control of child form when using showDialog() Pin
randor7-Nov-15 11:49
randor7-Nov-15 11:49 
AnswerRe: control of child form when using showDialog() Pin
Richard Andrew x647-Nov-15 11:55
professionalRichard Andrew x647-Nov-15 11:55 
AnswerRe: control of child form when using showDialog() Pin
BillWoodruff6-Nov-15 14:43
professionalBillWoodruff6-Nov-15 14:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.