תופעה מוזרה ב VS designer

pagis

New member
תופעה מוזרה ב VS designer

מכל מיני סיבות שאני מעדיף לא לפרט אני נאלץ לבנות GUI קטן. בכל מקרה, זה לא שלא בניתי GUI-ים בחיים שלי, למרות שזה מגעיל אני עושה את זה פה ושם אבל עכשיו זה עבר את הגבול. בניתי טופס פשוט, שיורש מטופס ריק (כלומר יורש רקע וצבעים וכו') ויש בו כפתורים רדיו, כפתורים תוויות ותיבת טקסט. אוקצור, הכל טוב ויפה וגם עובד (בנתיים עוד לא כתבתי כמעט קוד ביצוע, רק GUI) אבל ברגע שאני מנסה להוסיף ארוע (נאמר ארוע קליק לאחד הכפתורים) כל הרכיבים של הטופס נדחפים למעלה ולשמאל ויוצאים מהטופס. חוץ מזה הטקסט שהכנסתי אליהם נמחק ועוד כל מיני שטויות. קיצור, מה נסגר כאן????
public class MainForm : BaseForm { private System.Windows.Forms.Button btnShow; private System.Windows.Forms.Button btnResend; private System.Windows.Forms.RadioButton rbtnNew; private System.Windows.Forms.RadioButton rbtnOverwrite; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public MainForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.btnShow = new System.Windows.Forms.Button(); this.btnResend = new System.Windows.Forms.Button(); this.rbtnNew = new System.Windows.Forms.RadioButton(); this.rbtnOverwrite = new System.Windows.Forms.RadioButton(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // MainForm // this.Controls.Add(this.btnShow); this.Controls.Add(this.btnResend); this.Controls.Add(this.rbtnNew); this.Controls.Add(this.rbtnOverwrite); this.Controls.Add(this.textBox1); this.Controls.Add(this.label1); this.ResumeLayout(false); } #endregion​
 

HaRmosh

New member
אם אתה מוסיף את האירוע

בעצמך, כלומר נכנס ל-code view וכותב את הכל, זאת עלולה להיות הבעיה, כי ה-designer מאוד לא אוהב שמתערבים לו בקוד, לפחות בחלקים מסויימים. אם באמת זה מה שעשית, תוסיף את האירוע ע"י החלונית events (כמו properties, בצד כזה) - והוא יפנה אותך למקום המתאים בקוד עבור האירוע הזה, וגם יוסיף אותו לרשימת האירועים של הרכיב, וכל מה שצריך.
 

gilad g

New member
מעניין..

זה נראה כאילו נמחק לך קטע די רציני של הקוד מ-InitializeComponent(). יכול להיות שמחקת אותו בטעות
 

pagis

New member
לא, לא סביר.

כשייצרתי פרוייקט חדש שיורש מאותו טופס אב שוב היתה אותה התופעה. בסוף יצרתי פרוייקט חדש לגמרי, כולל טופס אב חדש. אני חייב לציין שאם לרגע תהיתי על אמינות החתימה שלי, התחזקתי באמונתי.
 
למעלה