نمایش نتایج 1 تا 40 از 533

نام تاپیک: 1001 نکته در سی شارپ

Hybrid View

پست قبلی پست قبلی   پست بعدی پست بعدی
  1. #1

    Lightbulb تخصیص آیکن سفارشی به کامپوننتهای درون تولباکس

    برای افزودن آیکن مورد نظر خود به یک کامپوننت کافیست که موارد زیر را رعایت کنید :
    • فایل تصویر باید از نوع bitmap و دقیقا همنام کلاس اما با پسوند bmp باشد
    • اندازه ی تصویر مربوطه باید حتما 16x16 باشد وگرنه بصورت اتوماتیک برای رسیدن به آن سایز بریده خواهد شد.
    • تصویر انتخابی باید از نوع 16 رنگ باشد
    • و ...
    برای توضیحات کاملتر گوشه هایی از متن اصلی کتاب رو مشاهده میکنید :
    The Toolbox Icon
    Adding a Toolbox icon is refreshingly easy. All you need to do is add a bitmap to your project and follow
    these rules:
    • The bitmap file must have the same name as your custom control class (but with the extension
    .bmp). For example, you would use a bitmap named CustomTextBox.bmp for the
    CustomTextBox control.
    • The bitmap must be 16×16 pixels. Otherwise, it will be mangled when Visual Studio
    attempts to scale it.
    • The bitmap must use only 16 colors.
    • Once you add the bitmap file, you must use the Properties window to set the Build Action to
    Embedded Resource.

    Incidentally, it’s possible to use a toolbox icon that uses a filename that doesn’t match the name
    of your control class. In this case, you need the help of the ToolboxBitmap attribute. For example, the
    following code configures the CustomTextBox control to use a bitmap named CustomTextBox1.bmp:
     [ToolboxBitmap(typeof(CustomTextBox), "CustomTextBox1.bmp")]
    public class CustomTextBox : WebControl, IPostBackDataHandler
    { ... }
    You can also use this trick to place bitmaps in a separate subfolder in your project. For example,
    here’s how you would refer to a bitmap in a folder named Images:
    [ToolboxBitmap(typeof(CustomTextBox), @"Images\CustomTextBox1.bmp")]
    Finally, it’s also possible to steal bitmaps from core ASP.NET controls, using code like this:
     [ToolboxBitmap(typeof(System.Web.UI.WebControls.Tex  tBox))]
    If you’re creating a simple control, all you may need to do is add a set of descriptive properties
    and a toolbox icon. However, more complex controls often require other considerations. These
    range from code serialization issues (how the control tag is created when you use the Properties window)
    to control designers (advanced tools for customizing the design-time HTML your control
    renders). In the rest of the chapter, you’ll take a look at these topics.
    منبع کتاب : http://www.amazon.com/Pro-ASP-NET-3-.../dp/1590598938
    آخرین ویرایش به وسیله sinpin : یک شنبه 18 فروردین 1387 در 05:50 صبح

برچسب های این تاپیک

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •