עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

הכנסת כל הצבעים לקומבו-בוקס בשפת C#

Featured Replies

פורסם

איך אני מקשר בין ה Struct של ה Color ל

ComboBox??

כך שכל הצבעים יופיעו בתוך הקומבו-בוקס כלל השמות???

פורסם

אם זה בגלל שאתה צריך לתת למשתמש אפשרות לבחור צבע , אז יש לך קומפוננטה מוכנה ColorDialog

אם אתה בכל זאת רוצה לעשות בעצמך קומבו כזה , מן הסתם תעשה 3 לולאות מקוננות מ- 0 עד 255 כדי לחולל את כל הקומבינציות של RGB

פורסם

שיניתי דוגמה שמצאתי בגוגל כדי שתעשה את מה שאתה רוצה:

      comboBox1.BeginUpdate();
Type colorType = Color.AliceBlue.GetType();
PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
int numOfProps = propInfoList.Length;

for (int i = 0; i < numOfProps; i++)
comboBox1.Items.Add(propInfoList[i].Name);

comboBox1.EndUpdate();

פורסם
  • מחבר

אתה יכול להסביר את הדוגמא שנתת?

פשוט לא מוכר לי ה binding שעשית שם.

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

פורסם

משתמשים ב Reflection כדי למצוא את כל המאפיינים (כל הצבעים) שהטיפוס Color מגדיר.

ה- BindingFlags מגדיר את המאפיינים שאתה צריך: סטטיים (כל הצבעים המוגדרים ב Color הם שדות סטטיים), מוגדרים אך ורק על ידי ה struct (כדי לא לקבל מאפיינים שה-struct ירש אלא רק הגדיר בעצמו) ומוגדרים כ- public.

אתה מוזמן לקרוא כאן הסבר מפורט יותר על כל ה BindingFlags:

http://msdn2.microsoft.com/en-us/library/system.reflection.bindingflags.aspx

ועל Reflection בכללי:

http://msdn2.microsoft.com/en-us/library/system.reflection.aspx

לאחר מכן אתה עובר על כל המאפיינים הללו ומוסיף את השם שלהם (שם הצבע) ל ComboBox.

פורסם
  • מחבר

תודה רבה רבה לך.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.