من یه Usercontrol تاریخ خودم درست کردم و درست کار می کنه ولی مشکلی که داره اینه که GotFocus اون اصلا کار نمی کنه و وقتی Focus روش میره بجای GotFocus رویداد LostFocus اجرا می شه ؟:متفکر:
از چی می تونه باشه ؟ :متعجب:
Printable View
من یه Usercontrol تاریخ خودم درست کردم و درست کار می کنه ولی مشکلی که داره اینه که GotFocus اون اصلا کار نمی کنه و وقتی Focus روش میره بجای GotFocus رویداد LostFocus اجرا می شه ؟:متفکر:
از چی می تونه باشه ؟ :متعجب:
آیا توی این کنترلی که ساختی چند تا کنترل دیگه قرار گرفتن، مثل کمبوبوکس، تکست باکس یا ... ؟
بله .دقیقا . 4 تا textbox هست که داخل یه Textbox بزرگتر هستن.
خوب. ببینید، وقتی شما یک کنترل رو خودتون می سازید، روی یک فرم ابزارهای مورد نظر خودتون (text boxها) رو کنار هم قرار دادید و بین اونها ارتباط برقرار کردید. یعنی شما یک کنترل مرکب از چند کنترل مرکب ایجاد کردید.
در این حالت با وجود اینکه کنترلی که شما ساختید از بیرون یک کنترل به نظر می رسه اما از طرف دیگر بین کنترلهایی که کنار هم قرار دادید این دید وجود نداره.
در حقیقت زمان استفاده از کنترلتتون این اتفاق می افته. شما کنترلی رو که خودتون ساختید رو به فرم برنامتون اضافه می کنید. برنامه رو اجرا می کنید و سپس روی کنترل کلیک می کنید، کنترل ساخت شما، فوکاس رو می گیره و به یکی از کنترلهای داخلش می ده. پس فوکاس رو از دست می ده.
من همین مشکل رو تو کنترلهایی که می ساختم داشتم. شما باید کنترلتون رو جوری بنویسید که اگه جعبه متنهای درونش فوکاس رو یا نگیرن و یا اگه گرفتن به کنترل اصلی بدن.
امیدوارم کمکی کرده باشم.
ممنون.دقیقا درست می گید