Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > .NET Framework > Forum > ขอถามเรื่อง Menustrip ใน vb.net ผมอยากจะทำ Menustripซ้อนกัน 2 From พอจะมีวิธีไหมครับ


 

[.NET] ขอถามเรื่อง Menustrip ใน vb.net ผมอยากจะทำ Menustripซ้อนกัน 2 From พอจะมีวิธีไหมครับ

 
Topic : 118550



โพสกระทู้ ( 201 )
บทความ ( 0 )



สถานะออฟไลน์



ขอถามเรื่อง Menustrip ใน vb2010.net ผมอยากจะทำ Menustrip โดยมี From 3 From
From1,From2,From3 พอจะมีวิธีไหมครับหรือทำได้แค่ From1,From 2 เท่านั้น

ตัวอย่าง
ผมกำหนดให้เมื่อกดเลือก A (From1)โดยset เป็น from หลัก

f1

Code (VB.NET)
1.Form2.MdiParent = Me
2.Form2.Show()

โดยที่ from2จะอยู่ภายใต้ from1 ดังรูป
จากนั้นเมื่อเรากดเลือก B ใน Menustrip ของ From2 เพื่อที่จะให้โชว์From3ภายใต้ From2ดังรูป

f3

มัน ERROR ดังรูปครับ

f4

พอจะมีวิธีอื่นที่ทำได้ไหมครับ



Tag : .NET, Ms SQL Server 2008, VB.NET



ประวัติการแก้ไข
2015-08-25 19:11:40
2015-08-25 19:11:41
2015-08-25 19:13:47
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-08-25 19:06:56 By : New_User View : 2040 Reply : 4
 

 

No. 1



โพสกระทู้ ( 201 )
บทความ ( 0 )



สถานะออฟไลน์


พอจะมีไหมหน้อ


ประวัติการแก้ไข
2015-08-26 08:37:38
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-26 08:07:03 By : New_User
 

 

No. 2



โพสกระทู้ ( 201 )
บทความ ( 0 )



สถานะออฟไลน์


เงียบเลย


ประวัติการแก้ไข
2015-08-26 12:56:58
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-26 12:47:39 By : New_User
 

 

No. 3



โพสกระทู้ ( 4,440 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

เหมือนจะทำไม่ได้อ่าครับ
แต่แนะนำให้ใช้ tabcontrol ครับ
เรียกหลายๆฟอรมได้

Code (C#)
001.using System;
002.using System.Collections.Generic;
003.using System.Linq;
004.using System.Windows.Forms;
005.using System.ComponentModel.Design;
006.using System.ComponentModel;
007.using System.Drawing;
008.using System.Drawing.Drawing2D;
009. 
010.namespace TORServices
011.{
012.    #region _SidTabControl
013.    public class cntlSidTabControl : System.Windows.Forms.TabControl
014.    {
015.        public void AddNewForm(Form form)
016.        {
017.            for (int i = 0; i < this.TabCount;i++ )
018.            {
019.                if (this.TabPages[i].Text == form.Text)
020.                {
021.                    this.TabIndex = i;
022.                    return;
023.                }
024.            }
025.            TabPage tab = new TabPage();
026.            this.Controls.Add(tab);
027.            form.TopLevel = false;
028.            form.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left);
029.            form.Dock = DockStyle.Fill;
030.            form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
031.            form.Parent = tab;
032.            tab.Text = form.Text;
033.            try { form.Show(); }
034.            catch { }
035.          
036.            this.SelectedTab = tab;
037. 
038.        }
039.        public cntlSidTabControl()
040.        {
041. 
042.            SetStyle(ControlStyles.DoubleBuffer, true);
043. 
044.            TabStop = false;
045. 
046.            DrawMode = TabDrawMode.OwnerDrawFixed;
047. 
048.            _closeButtonBrush = new SolidBrush(_closeButtonColor);
049. 
050.            ItemSize = new Size(ItemSize.Width, 24);
051. 
052.            // used to expand the tab header, find a better way
053. 
054.            Padding = new Point(16, 0);
055. 
056.        }
057. 
058.        protected override void Dispose(bool disposing)
059.        {
060. 
061.            if (disposing)
062.            {
063. 
064.                _stringFormat.Dispose();
065. 
066.                _closeButtonBrush.Dispose();
067. 
068.            }
069. 
070.            base.Dispose(disposing);
071. 
072.        }
073. 
074.        public delegate void TabClosedDelegate(object sender, ClosedEventArgs e);
075. 
076.        public delegate void TabClosingDelegate(object sender, ClosingEventArgs e);
077. 
078.        public event TabClosedDelegate TabClosed;
079. 
080.        public event TabClosingDelegate TabClosing;
081. 
082.        private int _buttonWidth = 16;
083. 
084.        [DefaultValue(16), Category("Action Buttons")]
085. 
086.        public int ButtonWidth
087.        {
088. 
089.            get { return _buttonWidth; }
090. 
091.            set { _buttonWidth = value; }
092. 
093.        }
094. 
095.        private int _crossOffset = 3;
096. 
097.        [DefaultValue(3), Category("Action Buttons")]
098. 
099.        public int CrossOffset
100.        {
101. 
102.            get { return _crossOffset; }
103. 
104.            set { _crossOffset = value; }
105. 
106.        }
107. 
108.        private readonly StringFormat _stringFormat = new StringFormat
109. 
110.        {
111. 
112.            Alignment = StringAlignment.Near,
113. 
114.            LineAlignment = StringAlignment.Center
115. 
116.        };
117. 
118.        private Color _closeButtonColor = Color.Red;
119. 
120.        private Brush _closeButtonBrush;
121. 
122.        [Category("Action Buttons")]
123. 
124.        public Color CloseButtonColor
125.        {
126. 
127.            get { return _closeButtonColor; }
128. 
129.            set
130.            {
131. 
132.                _closeButtonBrush.Dispose();
133. 
134.                _closeButtonColor = value;
135. 
136.                _closeButtonBrush = new SolidBrush(_closeButtonColor);
137. 
138.                Invalidate();
139. 
140.            }
141. 
142.        }
143. 
144.        protected override void OnDrawItem(DrawItemEventArgs e)
145.        {
146. 
147.            if (e.Bounds != RectangleF.Empty)
148.            {
149. 
150.                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
151. 
152.                for (int nIndex = 0; nIndex < TabCount; nIndex++)
153.                {
154. 
155.                    Rectangle tabArea = GetTabRect(nIndex);
156. 
157.                    Rectangle closeBtnRect = GetCloseBtnRect(tabArea);
158. 
159.                    if (nIndex != SelectedIndex)
160.                    {
161. 
162.                        e.Graphics.DrawRectangle(Pens.DarkGray, closeBtnRect);
163. 
164.                        DrawCross(e, closeBtnRect, Color.DarkGray);
165. 
166.                    }
167. 
168.                    else
169.                    {
170. 
171.                        //Drawing Close Button
172. 
173.                        e.Graphics.FillRectangle(_closeButtonBrush, closeBtnRect);
174. 
175.                        e.Graphics.DrawRectangle(Pens.White, closeBtnRect);
176. 
177.                        DrawCross(e, closeBtnRect, Color.White);
178. 
179.                    }
180. 
181.                    string str = TabPages[nIndex].Text;
182. 
183.                    e.Graphics.DrawString(str, Font, new SolidBrush(TabPages[nIndex].ForeColor), tabArea, _stringFormat);
184. 
185.                }
186. 
187.            }
188. 
189.        }
190. 
191.        private void DrawCross(DrawItemEventArgs e, Rectangle btnRect, Color color)
192.        {
193. 
194.            using (Pen pen = new Pen(color, 2))
195.            {
196. 
197.                float x1 = btnRect.X + CrossOffset;
198. 
199.                float x2 = btnRect.Right - CrossOffset;
200. 
201.                float y1 = btnRect.Y + CrossOffset;
202. 
203.                float y2 = btnRect.Bottom - CrossOffset;
204. 
205.                e.Graphics.DrawLine(pen, x1, y1, x2, y2);
206. 
207.                e.Graphics.DrawLine(pen, x1, y2, x2, y1);
208. 
209.            }
210. 
211.        }
212. 
213.        private Rectangle GetCloseBtnRect(Rectangle tabRect)
214.        {
215. 
216.            Rectangle rect = new Rectangle(tabRect.X + tabRect.Width - ButtonWidth - 4, (tabRect.Height - ButtonWidth) / 2, ButtonWidth, ButtonWidth);
217. 
218.            return rect;
219. 
220.        }
221. 
222.        protected override void OnMouseDown(MouseEventArgs e)
223.        {
224. 
225.            if (!DesignMode)
226.            {
227. 
228.                Rectangle rect = GetTabRect(SelectedIndex);
229. 
230.                rect = GetCloseBtnRect(rect);
231. 
232.                Point pt = new Point(e.X, e.Y);
233. 
234.                if (rect.Contains(pt))
235.                {
236. 
237.                    CloseTab(SelectedTab);
238. 
239.                }
240. 
241.            }
242. 
243.        }
244. 
245.        public void CloseTab(int tabindex)
246.        {
247. 
248.            CloseTab(TabPages[tabindex]);
249. 
250.        }
251. 
252.        public void CloseTab(TabPage tp)
253.        {
254. 
255.            ClosingEventArgs args = new ClosingEventArgs(TabPages.IndexOf(tp));
256. 
257.            OnTabClosing(args);
258. 
259.            //Remove the tab and fir the event tot he client
260. 
261.            if (!args.Cancel)
262.            {
263. 
264.                // close and remove the tab, dispose it too
265. 
266.                TabPages.Remove(tp);
267. 
268.                OnTabClosed(new ClosedEventArgs(tp));
269. 
270.                tp.Dispose();
271. 
272.            }
273. 
274.        }
275. 
276.        protected void OnTabClosed(ClosedEventArgs e)
277.        {
278. 
279.            if (TabClosed != null)
280.            {
281. 
282.                TabClosed(this, e);
283. 
284.            }
285. 
286.        }
287. 
288.        protected void OnTabClosing(ClosingEventArgs e)
289.        {
290. 
291.            if (TabClosing != null)
292. 
293.                TabClosing(this, e);
294. 
295.        }
296. 
297.    }
298. 
299.    //Some support classes:
300. 
301.    public class ClosingEventArgs
302.    {
303. 
304.        private readonly int _nTabIndex = -1;
305. 
306.        public ClosingEventArgs(int nTabIndex)
307.        {
308. 
309.            _nTabIndex = nTabIndex;
310. 
311.            Cancel = false;
312. 
313.        }
314. 
315.        public bool Cancel { get; set; }
316. 
317.        /// <summary>
318. 
319.        /// Get/Set the tab index value where the close button is clicked
320. 
321.        /// </summary>
322. 
323.        public int TabIndex
324.        {
325. 
326.            get
327.            {
328. 
329.                return _nTabIndex;
330. 
331.            }
332. 
333.        }
334. 
335.    }
336. 
337.    public class ClosedEventArgs : EventArgs
338.    {
339. 
340.        private readonly TabPage _tab;
341. 
342.        public ClosedEventArgs(TabPage tab)
343.        {
344. 
345.            _tab = tab;
346. 
347.        }
348. 
349.        /// <summary>
350. 
351.        /// Get/Set the tab index value where the close button is clicked
352. 
353.        /// </summary>
354. 
355.        public TabPage Tab
356.        {
357. 
358.            get
359.            {
360. 
361.                return _tab;
362. 
363.            }
364. 
365.        }
366. 
367.    }
368. 
369.    #endregion
370.}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-26 13:25:16 By : lamaka.tor
 

 

No. 4



โพสกระทู้ ( 201 )
บทความ ( 0 )



สถานะออฟไลน์


อ้อๆขอบคุณครับพี่ๆ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-26 14:22:22 By : New_User
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอถามเรื่อง Menustrip ใน vb.net ผมอยากจะทำ Menustripซ้อนกัน 2 From พอจะมีวิธีไหมครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่