الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

How to set index in a container control ?

مغلق
بدأه adel_yacoubi في 24 مايو 2006 · 3 رد · 567 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Salaam all,

I have the following question :

How can i set index for a specific control in a container of controls ?

Specific example :

I want to make a panel , and whithin this panel 4 buttons.

I want to set index of each button at the design time.

Button2 : is the 4 th element of the panel.

Button1: the 4th element of the panel

...etc

Thus the problem is setting index of a control in DESIGN TIME.

I hope you van understand what my problem is.

Wa salamo 3alaykom wa ra7matou lahi wa barakatoh

#2

هل تقصد الـ Tab Index ؟

اذا كنت تقصده فيوجد خاصية TabIndex يمكنك تعديلها من نافذة الـ Properties. أو من خلال قائمة View اضغط على Tab Order ورتبهم كما تريد.

اذا كنت تقصد ترتيب الـ Z-Order فذلك يمكنك فعله من خلال الضغط بالزرار اليمين واختيار Bring to front و Send to back.

#Read

http://MoutazShams.blogspot.com

projects003.gif

أعتذر عن التغيب هذه الأيام نظرا للانشغال المريب

#3

Salaam,

Thanks my brother for your answer , but this is not what i want.

If i create a panel with a couple of controls inside it, the panel is an array of controls

if i want to display the texts of all controls of that panel i can do like this

for (int i = 0 ; i < panel1.Controls.Count; i++)

{

MessageBox.Show("Text = of " + i.ToString() + "de control is = " + panel1.Controls.Text);

}

But i dont have any control about index of each control in that panel, sometimes i get other results then what i m expecting.

Problem is thus : the index in that array.

Thanks

Panel is now an array of controls, how can i set the index of that array.

Button2 will be for example = panel1.Controls[2]

thus : setting index at design time

#4

عندما تضيف بعض الأدوات الى Panel مثلا. فان الـ Visual Studio تولد كود مشابه للتالي :

yourPanel.Controls.Add(yourButton1);
yourPanel.Controls.Add(yourButtonN);
... الخ

وعلى ما أذكر أن على أساس ذلك يتم تحديد الـ Z-Order للأدوات وهو بالطبع نفسه ترتيب الـ Index للأدوات في Collection الـ Controls الخاصه بالـ Panel أو بأى Container Control. واذا أردت تغيير الترتيب فقم بتعديل الكود المتولد .. مثلا تجعله هكذا :

... الخ
yourPanel.Controls.Add(yourButtonN);
yourPanel.Controls.Add(yourButton1);

ولكن التعديل في الكود الذي يقوم الـ Visual Studio بتوليده, قد يربكه ويشتت الـ Form Designer ولهذا لا ينصح بذلك. والبديل هنا هو أن تستخدم أوامر Bring to front و Send to back لتعدل الـ Z-Order الذي بدوره يعدل الكود المتولد نيابة عنك وبالتالي يعدل ترتيب الأدوات داخل Collection الـ Controls.

#Read

http://MoutazShams.blogspot.com

projects003.gif

أعتذر عن التغيب هذه الأيام نظرا للانشغال المريب

هذا الموضوع مغلق.

مواضيع مشابهة