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,028

HOME > .NET Framework > Forum > WinApp C# มาอีกแล้ว ครับ ปัญหา รอบดึก เกี่ยวกับ การเขียน User control ครับ



 

WinApp C# มาอีกแล้ว ครับ ปัญหา รอบดึก เกี่ยวกับ การเขียน User control ครับ

 



Topic : 133814



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



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



ผมนั่งเขียน user control ประมาณนี้ครับ

33

โค้ด

Code (C#)
namespace TORServices.FormsTor
{
    [
    ComVisible(true),
    ClassInterface(ClassInterfaceType.AutoDispatch),
    LookupBindingProperties("DataSource", "DisplayMember", "ValueMember", "SelectedValue")
    ]
    public partial class Textbox2AndButton : UserControl
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnSearch = new System.Windows.Forms.Button();
            this.txtID = new System.Windows.Forms.TextBox();
            this.panel1 = new System.Windows.Forms.Panel();
            this.txtDetail = new System.Windows.Forms.TextBox();
            this.panel2 = new System.Windows.Forms.Panel();
            this.SuspendLayout();
            // 
            // btnSearch
            // 
            this.btnSearch.Dock = System.Windows.Forms.DockStyle.Right;
            this.btnSearch.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.btnSearch.Image = global::TORServices.Properties.Resources.search_button32x32;
            this.btnSearch.Location = new System.Drawing.Point(315, 0);
            this.btnSearch.Margin = new System.Windows.Forms.Padding(4);
            this.btnSearch.Name = "btnSearch";
            this.btnSearch.Size = new System.Drawing.Size(28, 30);
            this.btnSearch.TabIndex = 0;
            this.btnSearch.UseVisualStyleBackColor = true;
            this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
            // 
            // txtID
            // 
            this.txtID.Dock = System.Windows.Forms.DockStyle.Left;
            this.txtID.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.txtID.Location = new System.Drawing.Point(0, 0);
            this.txtID.Margin = new System.Windows.Forms.Padding(4);
            this.txtID.Name = "txtID";
            this.txtID.Size = new System.Drawing.Size(68, 29);
            this.txtID.TabIndex = 1;
            this.txtID.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtID_KeyDown);
            this.txtID.Leave += new System.EventHandler(this.txtID_Leave);
            // 
            // panel1
            // 
            this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
            this.panel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.panel1.Location = new System.Drawing.Point(68, 0);
            this.panel1.Margin = new System.Windows.Forms.Padding(4);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(5, 30);
            this.panel1.TabIndex = 3;
            // 
            // txtDetail
            // 
            this.txtDetail.BackColor = System.Drawing.SystemColors.Window;
            this.txtDetail.Dock = System.Windows.Forms.DockStyle.Fill;
            this.txtDetail.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.txtDetail.Location = new System.Drawing.Point(73, 0);
            this.txtDetail.Margin = new System.Windows.Forms.Padding(4);
            this.txtDetail.Name = "txtDetail";
            this.txtDetail.ReadOnly = true;
            this.txtDetail.Size = new System.Drawing.Size(237, 29);
            this.txtDetail.TabIndex = 4;
            // 
            // panel2
            // 
            this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
            this.panel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.panel2.Location = new System.Drawing.Point(310, 0);
            this.panel2.Margin = new System.Windows.Forms.Padding(4);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(5, 30);
            this.panel2.TabIndex = 5;
            // 
            // Textbox2AndButton
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.txtDetail);
            this.Controls.Add(this.panel2);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.txtID);
            this.Controls.Add(this.btnSearch);
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.Margin = new System.Windows.Forms.Padding(4);
            this.Name = "Textbox2AndButton";
            this.Size = new System.Drawing.Size(343, 30);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button btnSearch;
        private System.Windows.Forms.TextBox txtID;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.TextBox txtDetail;



       


        private DataTable tblSource;
        private string _DisplayMember;
        private string _ValueMember;
        private Panel panel2;
        private string stSelectedValue;
        public Textbox2AndButton()
        {
            InitializeComponent();

        }

        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("TextID")]
        public string TextID
        {
            get
            {
                return this.txtID.Text;
            }
            set
            {
                this.txtID.Text = value;
            }
        }
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("TextDetail")]
        public string TextDetail
        {
            get
            {
                return this.txtDetail.Text;
            }
            set
            {
                this.txtDetail.Text = value;
            }
        }

        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("ImageButton")]
        public Image ImageButton
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return btnSearch.Image;
            }
            set
            {
                btnSearch.Image = value; Invalidate();
            }
        }

        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("Color text ID")]
        public Color ColortextID
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return txtID.BackColor;
            }
            set
            {
                txtID.BackColor = value; Invalidate();
            }
        }
        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("Color text ID")]
        public Color ColortextDetail
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return txtDetail.BackColor;
            }
            set
            {
                txtDetail.BackColor = value; Invalidate();
            }
        }

        protected override void OnFontChanged(EventArgs e)
        {
            base.OnFontChanged(e);
            txtDetail.Font = Font;
            txtID.Font = Font;
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            this.Height = txtID.Height;
            btnSearch.Width = btnSearch.Height;
        }
        public event EventHandler TextBoxTextChanged
        {
            add
            {
                txtID.TextChanged += value;
            }
            remove
            {
                txtID.TextChanged -= value;
            }
        }
        public event EventHandler TextBoxDetailTextChanged
        {
            add
            {
                txtDetail.TextChanged += value;
            }
            remove
            {
                txtDetail.TextChanged -= value;
            }
        }
        [
          DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
          RefreshProperties(RefreshProperties.All),
          ParenthesizePropertyName(true)
          ]
        public ControlBindingsCollection DataBindings
        {
            get
            {
                ControlBindingsCollection bindings = (ControlBindingsCollection)this.txtID.DataBindings;
                if (bindings == null)
                {
                    bindings = new ControlBindingsCollection(this);
                }
                return bindings;
            }

        }


        [Bindable(true)]
        [Category("Data")]
        [Description("Set DataSource")]
        public DataTable DataSource
        {
            get
            {
                return tblSource;
            }
            set
            {
                tblSource = value;
            }
        }

        [Category("Data")]
        [Editor(typeof(Textbox2AndButtonCaller), typeof(UITypeEditor))]
        [Description("Set field name in DisplayMember")]
        public string DisplayMember
        {
            get
            {
                return _DisplayMember;
            }
            set
            {
                _DisplayMember = value;
            }
        }

        [Category("Data")]
        [Editor(typeof(Textbox2AndButtonCaller), typeof(UITypeEditor))]
        [Description("Set field name in ValueMember")]
        public string ValueMember
        {
            get
            {
                return _ValueMember;
            }
            set
            {
                _ValueMember = value;
            }
        }
        [Browsable(false)]
        [DefaultValue("")]
        public string SelectedValue
        {
            get { return stSelectedValue; }
            set { stSelectedValue = value; }
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            Form parent = this.FindForm();
            Textbox2AndButtonChoseGrid popup = new Textbox2AndButtonChoseGrid(this);
            popup.Location = new Point(parent.Location.X + this.Location.X + 4, parent.Location.Y + this.Location.Y + this.Height + 30);

            popup.ShowDialog();

        }


        private void txtID_Leave(object sender, EventArgs e)
        {
            IDSearch();
        }

        private void IDSearch()
        {
            try
            {
                DataRow[] drs = tblSource.Select(ValueMember + " = " + txtID.Text);
                if (drs.Length >= 0)
                    txtDetail.Text = drs[0][DisplayMember].ToString();

            }
            catch { MessageBox.Show("Error! \n Data not found"); }

        }

        private void txtID_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode == Keys.Enter)
                IDSearch();
        }
    }

    public class Textbox2AndButtonCaller : UITypeEditor
    {
        #region Variables declaration

        private IWindowsFormsEditorService edSvc = null;
        private ListBox cboTableNames = null;

        #endregion

        #region Override Methods

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context != null && context.Instance != null)
            {
                return UITypeEditorEditStyle.DropDown;
            }
            return base.GetEditStyle(context);
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                Textbox2AndButton control = (Textbox2AndButton)context.Instance;
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    cboTableNames = new ListBox();
                    cboTableNames.BorderStyle = BorderStyle.FixedSingle;

                    for (int i = 0; i < control.DataSource.Columns.Count; i++)
                        cboTableNames.Items.Add(control.DataSource.Columns[i].ColumnName);

                    cboTableNames.SelectedIndexChanged += new EventHandler(cboTableNames_SelectedIndexChanged);
                    edSvc.DropDownControl(cboTableNames);
                    return cboTableNames.SelectedItem;
                }
            }
            return base.EditValue(context, provider, value);
        }

        #endregion

        #region Events

        private void cboTableNames_SelectedIndexChanged(object sender, EventArgs e)
        {
            cboTableNames.Text = (string)cboTableNames.SelectedItem;
            edSvc.CloseDropDown();
        }

        #endregion
    }
}


คือ ผมอยากให้ เลือก DataSource แล้ว ให้สร้าง BindingSource / Dataset/TableAdapter ลงในฟอร์มเลย ครับ

14

ผมงมอยู่ตั้งนานก็ยังหาไม่เจอว่าต้องเขียนยังไง

มาได้แค่นี้ครับ

15



Tag : .NET, Win (Windows App), C#







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2019-06-28 00:34:26 By : lamaka.tor View : 1939 Reply : 55
 

 

No. 1

Guest


Code (C#)
using System.Windows.Forms;

namespace CS
{
    [System.ComponentModel.DefaultBindingProperty("PhoneNumber")]
    public partial class PhoneNumberBox : UserControl
    {
        public string PhoneNumber
        {
            get{ return maskedTextBox1.Text; }
            set{ maskedTextBox1.Text = value; }
        }

        public PhoneNumberBox()
        {
            InitializeComponent();
        }
    }
}







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 07:17:27 By : xxx
 


 

No. 2

Guest


คุณเคยถามว่า แล้วยุคใหม่เขาเขียนกันอย่างไร? ยกตัวอย่างคร่าว <Table("Users")> คือตารางในฐานข้อมูลจริง
ทางเลือกคือ EF/Dapper แต่ผมเลือก Dapper

Code (VB.NET)
<Table("Users")>
Public Class Users

    <Key, Required, Column("UserId")>
    Public Property Id As Integer 'PK เขียนลง Database และเขียนลงคอลัมภ์ UserId

    <Column("UserName")>
    Public Property FirstName As String 'เขียนลง Database และให้เขียนลงคอลัมภ์ UserName

    <NotMapped>
    Public Property LastName As String 'ไม่เขียนลง Database

    <Key>
    Public Property AutoIncrementId As Integer 'ไม่เขียนลง Database

    <Dapper.ReadOnly(True)>
    Public Property CreatedDate As DateTime 'ไม่เขียนลง Database

End Class

 sexyDatabase.ConfigDatabase(SimpleCRUD.Dialect.SQLite) 'รองรับหลากหลาย ไม่พอก็เขียนเพิ่ม
    Using cn = SexyConnection()
        cn.Open() 'Open Connection
        Using trans = cn.BeginTransaction()
            Try
                Dim objUser As New Users() With {.Id = 6969, .FirstName = "นางสาว", .LastName = "นมโต"}
                'LastName มันไม่จัดเก็บลงฐานข้อมูล (ต้องสั่งได้ดั่งใจนึก)
                Dim success = cn.Insert(Of Users)(objUser)
                trans.Commit()
            Catch ex As ArgumentException
                trans.Rollback()
            End Try
        End Using
        cn.Close() 'Close Connection
    End Using

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 07:35:52 By : xxx
 

 

No. 3

Guest


จาก #NO1 ถ้าคุณยังไม่ได้คำตอบ ก็ผ่า Source Code ของ .NET ออกมาดู (Textbox Binding)
--- ผมเชื่อว่าคุณทำได้



ผมเห็นคำถามหลากหลาย เกี่ยวกับ การเขียนคำสั่ง Insert/Update/Delete/Query อทิเช่น

Insert into table (Field1, Field2) values (value1, value2)
Update table set field1 = value1, field2 = value2 where 1=1
Delete table Where 1=1

ผมก็ยังงงงง ว่า มหาวิทยาลัยของไทย ทำไมมันสอนย่ำอยู่กับที่ องค์ความรู้คับแคบยิ่งนัก
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 08:04:12 By : xxx
 


 

No. 4



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



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

ถ้าลงโค้ดมันก็ได้อยู่ครับ

แต่ใน Combobox คือ มันสร้าง BindingSource / Dataset/TableAdapter มาให้เราเลย โดยที่เราแค่ คลิกเลือกที่ data เองครับ
ผมอยากได้แบบนั้น แมะ (วันนี้รันเครื่อง แล้ว จะลองลุยต่ออีกรอบ)
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 08:17:09 By : lamaka.tor
 


 

No. 5

Guest


@TOR_CHEMISTRY
www.thaicreate.com โชคดีที่มีคนอย่างคุณ ขออนุญาติเอาคำอ้างของท่านอื่นมาเล่าอีกครั้ง
--- คุณเป็นคนที่ซุกซนในภาษาโปรแกรมมิ่ง หายาก
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 08:58:05 By : xxx
 


 

No. 6



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


user control คุณจะ inherit จากอะไรครับ
ก็แค่เพิ่ม property dataset เข้าไป เขียน get / set เพื่อใช้ อ้างอิง ในการทำ binding
โดยกำหนด ตัวแปร dataset มารับ ค่าจาก Property

และให้ component ใน user control นั้น อ้างอิง จาก ตัวแปร dataset


ประวัติการแก้ไข
2019-06-28 09:03:56
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 09:02:02 By : Chaidhanan
 


 

No. 7

Guest


็Happy Birth day มหาเทพท่านหน้าฮี 28/06/2019
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 09:07:47 By : xxx
 


 

No. 8



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



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

ตอบความคิดเห็นที่ : 6 เขียนโดย : Chaidhanan เมื่อวันที่ 2019-06-28 09:02:02
รายละเอียดของการตอบ ::
ตามโค้ดที่ผมแนบด้านบน ก็จะมี 2 textbox 1 button ครับ

ตรง textbox ตัวหนึ่ง รับเป็น ID มา ถ้าเปรียบกับ combobox ก็จะประมาณว่ารับ ValueMember ไว้ ครับ
textbox ตัวหนึ่ง รับเป็น Text มา ถ้าเปรียบกับ combobox ก็จะประมาณว่ารับ DisplayMember ไว้ ครับ
ส่วนปุ่มไว้กด ให้มี datagrid โผล่มาให้เลือก ครับ

get / set ผมมีแล้วครับ

Code (C#)
  [
          DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
          RefreshProperties(RefreshProperties.All),
          ParenthesizePropertyName(true)
          ]
        public ControlBindingsCollection DataBindings
        {
            get
            {
                ControlBindingsCollection bindings = (ControlBindingsCollection)this.txtID.DataBindings;
                if (bindings == null)
                {
                    bindings = new ControlBindingsCollection(this);
                }
                return bindings;
            }

        }


        [Bindable(true)]
        [Category("Data")]
        [Description("Set DataSource")]
        public DataTable DataSource
        {
            get
            {
                return tblSource;
            }
            set
            {
                tblSource = value;
            }
        }

        [Category("Data")]
        [Editor(typeof(Textbox2AndButtonCaller), typeof(UITypeEditor))]
        [Description("Set field name in DisplayMember")]
        public string DisplayMember
        {
            get
            {
                return _DisplayMember;
            }
            set
            {
                _DisplayMember = value;
            }
        }

        [Category("Data")]
        [Editor(typeof(Textbox2AndButtonCaller), typeof(UITypeEditor))]
        [Description("Set field name in ValueMember")]
        public string ValueMember
        {
            get
            {
                return _ValueMember;
            }
            set
            {
                _ValueMember = value;
            }
        }
        [Browsable(false)]
        [DefaultValue("")]
        public string SelectedValue
        {
            get { return stSelectedValue; }
            set { stSelectedValue = value; }
        }


ผมเหลือแค่ให้มันสมบูรณ์ เหมือน combobox แค่นั้นครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 09:14:11 By : lamaka.tor
 


 

No. 9

Guest


มหาเทพ Chaidhanan
เคยเขึยน Script Shell บน UNIX ไหมครับ ถ้าเคย พอมีตัวอย่างไหมครับ
ขอบพระคุณมากครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 09:24:08 By : xxx
 


 

No. 10



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



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

จากที่ผมลองแกะมา รู้สึกว่า combobox มันอ้างจาก ListControl แล้ว ListControl ก็อ้างจาก Control อีกทีครับ


https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed/System/WinForms/ComboBox.cs

https://referencesource.microsoft.com/#system.windows.forms/winforms/managed/system/winforms/ListControl.cs

https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed/System/WinForms/Control.cs,9884211b7ff61817
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 09:30:47 By : lamaka.tor
 


 

No. 11

Guest


Quote:
จากที่ผมลองแกะมา รู้สึกว่า combobox มันอ้างจาก ListControl แล้ว ListControl ก็อ้างจาก Control อีกทีครับ


https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed/System/WinForms/ComboBox.cs

https://referencesource.microsoft.com/#system.windows.forms/winforms/managed/system/winforms/ListControl.cs

https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed/System/WinForms/Control.cs,9884211b7ff61817



ชี้เป้าให้แล้ว มันต้องอย่างนี้
เยี่ยมยอด ผมปรบมือให้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:09:20 By : xxx
 


 

No. 12



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



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

Error แบบนี้ เราลบ มันออกเลยได้ไม๊ครับ มีผลกับ โค้ดอื่นๆ ไม๊

66

ใน .net ที่โหลดมาก็ Error เหมือนกัน เลยไม่รู้ว่ามันอ้างอิงจากตรงไหนมาครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:09:38 By : lamaka.tor
 


 

No. 13

Guest


Quote:
มหาเทพ Chaidhanan
เคยเขึยน Script Shell บน UNIX ไหมครับ ถ้าเคย พอมีตัวอย่างไหมครับ
ขอบพระคุณมากครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:10:44 By : xxx
 


 

No. 14

Guest


Quote:
Error แบบนี้ เราลบ มันออกเลยได้ไม๊ครับ มีผลกับ โค้ดอื่นๆ ไม๊


ทำสองอัน แยกกัน

TestProject --> Local
ProductionProject --> Real


มันก็ไม่น่าจะส่งผลกระทบอะไร


ปล. ทุกฯอย่างได้มาจากการ ลองผิด/ลองถูก และไม่มีอะไรสมบูรณ์แบบ ณ.เวลาปัจจุบัน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:13:21 By : xxx
 


 

No. 15



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



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

ตอบความคิดเห็นที่ : 14 เขียนโดย : xxx เมื่อวันที่ 2019-06-28 10:13:21
รายละเอียดของการตอบ ::
อืมมมมมมมมมมมมมมมมมมมม

ตอนนี้ผมยังนั่งไล่แก้โค้ด ไม่หมดเลยครับ

666

Error แต่ละตัวเกินสมองอันน้อยนิดของผมทั้งนั้นเลยครับ

สงสัยครับ
ทำไม คลาส ของผมถึงใช้ abstract ไม่ได้ หรือครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:33:10 By : lamaka.tor
 


 

No. 16

Guest


ท่านหน้าฮีเคยเล่าให้ผมฟังว่า ลองไปเล่น Blazor ดูซิ
ผมก็ได้แย้งท่านไปว่า ผมกลัวมันจะซ้ำรอยเดิม (ของดีแต่ไม่มีอนาคต)
--- Flash VS Blend สุดท้ายไม่ตายก็เหมือนตาย ทั้งคู่ (กอดคอกันตาย)
--- Windows Phone/นึกชื่อไม่ออก สมัย VS2005 -VS2008 มา VS2010 หายไปเลย

ท่านใช้ความเงียบแทนคำตอบ แต่ท่านพยักหน้า
--- และท่านก็รำพึงรำพัน "ก็ว่ากันไป ก็เมียกูหนีตามชู้ไป แล้วจะให้ทำอะไรได้"


ผมอดคิดสงสารไม่ได้ แต่ก็ไม่ได้รำพึงรำพันอะไร?
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:37:32 By : xxx
 


 

No. 17



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


รายละเอียด โปรแกรม c# คุณ tor ชำนาญกว่าผมเยอะครับ ผมไม่ค่อยได้เขียน c# หรอกครับ ยกเว้นจำเป็นจริงๆ
ปกติผมจะเขียน pascal oop 100% เมื่อก่อนใช้ radstudio ตอนนี้ใช้ lazarus ตรงที่มันเป็น free open-source 5555 ชอบของฟรี

ส่วนโค๊ดมีเก็บไว้ไหม ไม่มีหรอกครับ ผมไม่ได้เก็บไว้ ครับ ให้คนจ้างหมด หมดโปรฯ ก็จบไม่เก็บ
เพราะโค๊ดเก่าเอาเข้าจริงๆ สูเขียนใหม่ไม่ได้ เขียนเอง ยังต้องมานั่งวิเคราะห์ ของเก่าเขียนไว้ยังไงหว่า 55555
ส่วนลูกค้าเก่า ก็อาศัยเขาเก็บเอง ถ้าเขาเก็บไม่ดี ก็ช่วยไม่ได้แล้วครับ

ส่วน script shell จะใช้งาน ส่วนไหนครับ เอาไปรัน command line หรือยังไงครับ
แบบนี้หรือเปล่า
Code
if ["$1" = ""]; then exit fi echo "wget http://url.com/Centos7/$1.txt" wget http://url.com/Centos7/$1.txt mv $1.txt $1.sh chmod +x $1.sh bash $1.sh



ประวัติการแก้ไข
2019-06-28 10:55:36
2019-06-28 11:04:17
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:38:48 By : Chaidhanan
 


 

No. 18



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


ตอบความคิดเห็นที่ : 15 เขียนโดย : lamaka.tor เมื่อวันที่ 2019-06-28 10:33:10
รายละเอียดของการตอบ ::
component ไร้รูป กับ component มีรูป


คือ component ไร้รูป มันจะ contain component มีรูปไม่ได้ครับ
ผมถีงถาม คุณจะ inherit จากอะไร

ถ้าเป็น component มีรูป พื้นฐานก็ควรจะเริ่มจาก form panel
ถ้าเป็น component ไร้รูป ก็ class object ธรรมดา
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:47:19 By : Chaidhanan
 


 

No. 19

Guest


ส่วน script shell จะใช้งาน ส่วนไหนครับ เอาไปรัน command line หรือยังไงครับ


ผมพยายามรักษาความสุภาพเอาไว้ กระผมไม่ทราบ/กระผมไม่รู้

ท่านพอจะอธิบายคร่าวฯให้กระผมฟังได้ไหมครับ
ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:50:42 By : xxx
 


 

No. 20



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



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

ตอบความคิดเห็นที่ : 18 เขียนโดย : Chaidhanan เมื่อวันที่ 2019-06-28 10:47:19
รายละเอียดของการตอบ ::
ขอผมทำความความเข้าใจนะครับ

Code (C#)
public partial class Textbox2AndButton : UserControl
    {
        public Form1()
        {
            InitializeComponent();
        }
    }


แบบนี้คือ component มีรูป เพราะมันอิงมาจาก UserControl
และ

Code (C#)
 abstract class Customer
    {
        public void PrintCustomer()
        {
            Console.WriteLine("Customer X");
        }
        public abstract void PrintCustomerAddress();
    }

    class UnitTest : Customer  //extends
    {
        public override void PrintCustomerAddress()
        {
            Console.WriteLine("CustomerAddress");
        }
    }


ก็คือ component ไร้รูป ผมเข้าใจถูกไม๊ครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:54:09 By : lamaka.tor
 


 

No. 21

Guest


กระผมไม่รู้จริงฯ (ท่านหน้าฮี บอกผมว่าเอาไอ้นี่ไปทำ)
--- เอกสารหน้าเดียวก็ไม่มี มีแต่เอาไอ้นี่ไปทำ


งง งง งง

แต่ผมก็ไม่กล้าโต้แย้งอะไร?
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 10:59:24 By : xxx
 


 

No. 22



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



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

แก้ครบ ไม่มี Error แล้ว แต่พอลากลง ฟอร์ม เจอเต็มๆ

999


โค้ด ครับ

Code (C#)
        #region _DataBindings

        private static readonly object EVENT_DATASOURCECHANGED = new object();
        private static readonly object EVENT_DISPLAYMEMBERCHANGED = new object();
        private static readonly object EVENT_VALUEMEMBERCHANGED = new object();
        private static readonly object EVENT_SELECTEDVALUECHANGED = new object();

        private object dataSource;
        private CurrencyManager dataManager;
        private BindingMemberInfo displayMember;
        private BindingMemberInfo valueMember;

        // Formatting stuff
        private string formatString = String.Empty;
        private static readonly object EVENT_FORMAT = new object();
        private TypeConverter displayMemberConverter = null;

        private bool isDataSourceInitialized;
        private bool isDataSourceInitEventHooked;
        private bool inSetDataConnection = false;

        [
       DefaultValue(null),
       RefreshProperties(RefreshProperties.Repaint),
       AttributeProvider(typeof(IListSource))
       ]
        public object DataSource
        {
            get
            {
                return dataSource;
            }
            set
            {
                if (value != null && !(value is IList || value is IListSource))
                    throw new ArgumentException("BadDataSourceForComplexBinding");
                if (dataSource == value)
                    return;
                try
                {
                    SetDataConnection(value, displayMember, false);
                }
                catch
                {
                    DisplayMember = "";
                }
                if (value == null)
                    DisplayMember = "";
            }
        }

        public event EventHandler DataSourceChanged
        {
            add
            {
                Events.AddHandler(EVENT_DATASOURCECHANGED, value);
            }
            remove
            {
                Events.RemoveHandler(EVENT_DATASOURCECHANGED, value);
            }
        }


        protected CurrencyManager DataManager
        {
            get
            {
                return this.dataManager;
            }
        }

        [
       DefaultValue("")//,
       //TypeConverterAttribute("System.Windows.Forms.Design.DataMemberFieldConverter, " ),
      // Editor("System.Windows.Forms.Design.DataMemberFieldEditor, " , typeof(System.Drawing.Design.UITypeEditor))
       ]
        public string DisplayMember
        {
            get
            {
                return displayMember.BindingMember;
            }
            set
            {
                BindingMemberInfo oldDisplayMember = displayMember;
                try
                {
                    SetDataConnection(dataSource, new BindingMemberInfo(value), false);
                }
                catch
                {
                    displayMember = oldDisplayMember;
                }
            }
        }


        public event EventHandler DisplayMemberChanged
        {
            add
            {
                Events.AddHandler(EVENT_DISPLAYMEMBERCHANGED, value);
            }
            remove
            {
                Events.RemoveHandler(EVENT_DISPLAYMEMBERCHANGED, value);
            }
        }


        private TypeConverter DisplayMemberConverter
        {
            get
            {
                if (this.displayMemberConverter == null &&
                    this.DataManager != null &&
                    this.displayMember != null)
                {
                    PropertyDescriptorCollection props = this.DataManager.GetItemProperties();
                    if (props != null)
                    {
                        PropertyDescriptor displayMemberProperty = props.Find(this.displayMember.BindingField, true);
                        if (displayMemberProperty != null)
                        {
                            this.displayMemberConverter = displayMemberProperty.Converter;
                        }
                    }
                }
                return this.displayMemberConverter;
            }
        }

      


        private bool BindingMemberInfoInDataManager(BindingMemberInfo bindingMemberInfo)
        {
            if (dataManager == null)
                return false;
            PropertyDescriptorCollection props = dataManager.GetItemProperties();
            int propsCount = props.Count;

            for (int i = 0; i < propsCount; i++)
            {
                if (typeof(IList).IsAssignableFrom(props[i].PropertyType))
                    continue;
                if (props[i].Name.Equals(bindingMemberInfo.BindingField))
                {
                    return true;
                }
            }

            for (int i = 0; i < propsCount; i++)
            {
                if (typeof(IList).IsAssignableFrom(props[i].PropertyType))
                    continue;
                if (String.Compare(props[i].Name, bindingMemberInfo.BindingField, true, CultureInfo.CurrentCulture) == 0)
                {
                    return true;
                }
            }

            return false;
        }

        /* [
         DefaultValue(""),
         Editor("System.Windows.Forms.Design.DataMemberFieldEditor, " + AssemblyRef.SystemDesign, typeof(System.Drawing.Design.UITypeEditor))
         ]*/
        [
        DefaultValue("")/*,
        Editor("System.Windows.Forms.Design.DataMemberFieldEditor, ", typeof(System.Drawing.Design.UITypeEditor))*/
        ]
        public string ValueMember
        {
            get
            {
                return valueMember.BindingMember;
            }
            set
            {
                if (value == null)
                    value = "";
                BindingMemberInfo newValueMember = new BindingMemberInfo(value);
                BindingMemberInfo oldValueMember = valueMember;
                if (!newValueMember.Equals(valueMember))
                {

                    if (DisplayMember.Length == 0)
                        SetDataConnection(DataSource, newValueMember, false);
                    if (this.dataManager != null && value != null && value.Length != 0)
                        if (!BindingMemberInfoInDataManager(newValueMember))
                        {
                            throw new ArgumentException("ListControlWrongValueMember ");
                        }

                    valueMember = newValueMember;
                    OnValueMemberChanged(EventArgs.Empty);
                    OnSelectedValueChanged(EventArgs.Empty);
                }
            }
        }

        public event EventHandler ValueMemberChanged
        {
            add
            {
                Events.AddHandler(EVENT_VALUEMEMBERCHANGED, value);
            }
            remove
            {
                Events.RemoveHandler(EVENT_VALUEMEMBERCHANGED, value);
            }
        }

        protected virtual bool AllowSelection
        {
            get
            {
                return true;
            }
        }


    

        protected object FilterItemOnProperty(object item)
        {
            return FilterItemOnProperty(item, displayMember.BindingField);
        }


        protected object FilterItemOnProperty(object item, string field)
        {
            if (item != null && field.Length > 0)
            {
                try
                {
                    // if we have a dataSource, then use that to display the string
                    PropertyDescriptor descriptor;
                    if (this.dataManager != null)
                        descriptor = this.dataManager.GetItemProperties().Find(field, true);
                    else
                        descriptor = TypeDescriptor.GetProperties(item).Find(field, true);
                    if (descriptor != null)
                    {
                        item = descriptor.GetValue(item);
                    }
                }
                catch
                {
                }
            }
            return item;
        }

        //We use  this to prevent getting the selected item when mouse is hovering over the dropdown.
        //
        internal bool BindingFieldEmpty
        {
            get
            {
                return (displayMember.BindingField.Length > 0 ? false : true);
            }

        }

      


        protected override bool IsInputKey(Keys keyData)
        {
            if ((keyData & Keys.Alt) == Keys.Alt) return false;
            switch (keyData & Keys.KeyCode)
            {
                case Keys.PageUp:
                case Keys.PageDown:
                case Keys.Home:
                case Keys.End:
                    return true;
            }
            return base.IsInputKey(keyData);
        }


        protected override void OnBindingContextChanged(EventArgs e)
        {
            SetDataConnection(dataSource, displayMember, true);

            base.OnBindingContextChanged(e);
        }



        protected virtual void OnDataSourceChanged(EventArgs e)
        {
            EventHandler eh = Events[EVENT_DATASOURCECHANGED] as EventHandler;
            if (eh != null)
            {
                eh(this, e);
            }
        }


        protected virtual void OnDisplayMemberChanged(EventArgs e)
        {
            EventHandler eh = Events[EVENT_DISPLAYMEMBERCHANGED] as EventHandler;
            if (eh != null)
            {
                eh(this, e);
            }
        }

        protected virtual void OnFormat(ListControlConvertEventArgs e)
        {
            ListControlConvertEventHandler eh = Events[EVENT_FORMAT] as ListControlConvertEventHandler;
            if (eh != null)
                eh(this, e);
        }

       
        protected virtual void OnSelectedIndexChanged(EventArgs e)
        {
            OnSelectedValueChanged(EventArgs.Empty);
        }
        protected virtual void OnValueMemberChanged(EventArgs e)
        {
            EventHandler eh = Events[EVENT_VALUEMEMBERCHANGED] as EventHandler;
            if (eh != null)
            {
                eh(this, e);
            }
        }

        protected virtual void OnSelectedValueChanged(EventArgs e)
        {
            EventHandler eh = Events[EVENT_SELECTEDVALUECHANGED] as EventHandler;
            if (eh != null)
            {
                eh(this, e);
            }
        }

       //protected abstract void RefreshItem(int index);

        protected virtual void RefreshItems()
        {
        }

        private void DataSourceDisposed(object sender, EventArgs e)
        {
            Debug.Assert(sender == this.dataSource, "how can we get dispose notification for anything other than our dataSource?");
            SetDataConnection(null, new BindingMemberInfo(""), true);
        }

        private void DataSourceInitialized(object sender, EventArgs e)
        {
            ISupportInitializeNotification dsInit = (this.dataSource as ISupportInitializeNotification);
            Debug.Assert(dsInit != null, "ListControl: ISupportInitializeNotification.Initialized event received, but current DataSource does not support ISupportInitializeNotification!");
            Debug.Assert(dsInit.IsInitialized, "ListControl: DataSource sent ISupportInitializeNotification.Initialized event but before it had finished initializing.");
            SetDataConnection(this.dataSource, this.displayMember, true);
        }

        private void SetDataConnection(object newDataSource, BindingMemberInfo newDisplayMember, bool force)
        {
            bool dataSourceChanged = dataSource != newDataSource;
            bool displayMemberChanged = !displayMember.Equals(newDisplayMember);
            if (inSetDataConnection)
            {
                return;
            }
            try
            {
                if (force || dataSourceChanged || displayMemberChanged)
                {
                    inSetDataConnection = true;
                    IList currentList = this.DataManager != null ? this.DataManager.List : null;
                    bool currentManagerIsNull = this.DataManager == null;

                    UnwireDataSource();

                    dataSource = newDataSource;
                    displayMember = newDisplayMember;

                    WireDataSource();

                    if (isDataSourceInitialized)
                    {

                        CurrencyManager newDataManager = null;
                        if (newDataSource != null && BindingContext != null && !(newDataSource == Convert.DBNull))
                        {
                            newDataManager = (CurrencyManager)BindingContext[newDataSource, newDisplayMember.BindingPath];
                        }

                        if (dataManager != newDataManager)
                        {


                            dataManager = newDataManager;
                        }

                        if (dataManager != null && (displayMemberChanged || dataSourceChanged) && displayMember.BindingMember != null && displayMember.BindingMember.Length != 0)
                        {

                            if (!BindingMemberInfoInDataManager(displayMember))
                                throw new ArgumentException("ListControlWrongDisplayMember ");
                        }

                       
                    }
                    this.displayMemberConverter = null;
                }

                if (dataSourceChanged)
                {
                    OnDataSourceChanged(EventArgs.Empty);
                }

                if (displayMemberChanged)
                {
                    OnDisplayMemberChanged(EventArgs.Empty);
                }
            }
            finally
            {
                inSetDataConnection = false;
            }
        }

        private void UnwireDataSource()
        {
            // If the source is a component, then unhook the Disposed event
            if (this.dataSource is IComponent)
            {
                ((IComponent)this.dataSource).Disposed -= new EventHandler(DataSourceDisposed);
            }

            ISupportInitializeNotification dsInit = (this.dataSource as ISupportInitializeNotification);

            if (dsInit != null && isDataSourceInitEventHooked)
            {
                dsInit.Initialized -= new EventHandler(DataSourceInitialized);
                isDataSourceInitEventHooked = false;
            }
        }

        private void WireDataSource()
        {
            if (this.dataSource is IComponent)
            {
                ((IComponent)this.dataSource).Disposed += new EventHandler(DataSourceDisposed);
            }

            ISupportInitializeNotification dsInit = (this.dataSource as ISupportInitializeNotification);

            if (dsInit != null && !dsInit.IsInitialized)
            {
                dsInit.Initialized += new EventHandler(DataSourceInitialized);
                isDataSourceInitEventHooked = true;
                isDataSourceInitialized = false;
            }
            else
            {
                isDataSourceInitialized = true;
            }
        }

       // protected abstract void SetItemsCore(IList items);
        protected virtual void SetItemCore(int index, object value) { }


        #endregion

ผมละนึกถึงเพลงนี้เลย

https://www.youtube.com/watch?v=7YiuUaHUqSg

แบบนี้ ผมต้องเขียน DataMemberFieldEditor หรือ ตัว Editor เองใช่ไม๊ครับ
ถ้าใช่ พอจะมีตัวอย่างให้แกะไม๊ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:01:30 By : lamaka.tor
 


 

No. 23



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


ที่ผมรู้ ตอบความคิดเห็นที่ : 19 เขียนโดย : xxx เมื่อวันที่ 2019-06-28 10:50:42
รายละเอียดของการตอบ ::
ที่ผมรู้ script shell ก็เหมือนกับ batch file ใช้รวม command line ไว้ด้วยกัน ครับ


ตัวอย่าง
Code (SQL)
if ["$1" = ""]; then
  exit
fi
echo "wget http://url.com/Centos7/$1.txt"
wget http://url.com/Centos7/$1.txt
mv $1.txt $1.sh
chmod +x $1.sh
bash $1.sh



ประวัติการแก้ไข
2019-06-28 11:03:20
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:02:13 By : Chaidhanan
 


 

No. 24

Guest


ผมอดทนอดกลั้น และกล้าถามท่านหน้าฮีว่า ท่านจะให้ผมทำอะไรกับสิ่งที่ผมไม่รู้
ท่านหน้าฮีตอบว่า : กูก็ไม่รู้ เหมือนกัน


คำตอบเดียวที่ทำให้ผมหัวเราะได้ และคลายความกังวล
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:09:07 By : xxx
 


 

No. 25

Guest


Quote:
if ["$1" = ""]; then
exit
fi
echo "wget http://url.com/Centos7/$1.txt"
wget http://url.com/Centos7/$1.txt
mv $1.txt $1.sh
chmod +x $1.sh
bash $1.sh




กระผมเข้าใจแล้วครับ ขอบคุณมากฯฯฯ ครับ มหาเทพ Chaidhanan
ต่อไปผมไม่จำเป็นต้องง้อ ไอ้หน้าฮีมันอีกแล้ว

ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:11:52 By : xxx
 


 

No. 26

Guest


แจ่มแมว ไอ้ xxx

มันต้องอย่างนี้ซิ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:15:48 By : หน้าฮี
 


 

No. 27

Guest


@Chaidhanan
กรุณาส่ง Profile มาให้กระผมหน่อยครับ ผมขอร้อง
4000 x 30
[email protected]
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:19:17 By : หน้าฮี
 


 

No. 28



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


ขี้เกียจอธิบายยาวเกิน เลยไปหามาให้
https://mystou.com/java-abstract-class/
แม้ไม่ใช้ c# แต่หลักการเหมือนกัน pascal ก็เหมือนกัน หลักการเขียน oop เหมือนกัน

ที่นี้ abstract class สามารถ สร้าง component แบบมีรูปได้
แต่ ผู้ที่จะ contain มัน ( parent class ) จะต้องมี รูป แค่ต้องกำหนด ให้มัน จะอยู่แบบลอยๆ ไม่ได้

เริ่มต้นคลาสแบบมีรูป อย่าทำแบบ abstract แบบง่ายที่สุดให้ inherit จาก component แบบมีรูป เช่น form หรือ panel

เมื่อก่อนผมก็คิดจะเขียน class component แบบมีรูป เอง อั๋ยยะ โคตรจะยุ่งยากเลย เอาวิธีง่ายๆ inherit เอาง่ายกว่าเยอะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:24:18 By : Chaidhanan
 


 

No. 29

Guest


ขอบคุณครับ มหาเทพ Chaidhanan และผมขอบคุณแทนเจ้า xxx
อย่าลืมส่งของมาให้ผมนะครับ ผมขอร้อง


ผมไม่ได้สนใจ Delphi/C#/VB.NET/etc.. เขียนไม่เป็นยิ่งดี


ขอบคุณครับ มหาเทพของผม
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:35:49 By : หน้าฮี
 


 

No. 30



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


ตอบความคิดเห็นที่ : 27 เขียนโดย : หน้าฮี เมื่อวันที่ 2019-06-28 11:19:17
รายละเอียดของการตอบ ::
จะเอาโปรไฟล์ไปทำอะไรเหรอครับ ประกาศจับหรือเปล่า 555555


ผมเคยทำงาน ที่ รัฐวิสหกิจด้านพลังงาน 7 ปี
หนังสือพิมพ์ 7 ปี
เวป ข่าว กีฬา 7 ปี
นอกนั้นก็ทำ free lance มาตลอด
เลข 7 มันน่าเบื่อตอนจะขึ้นปีที่ 8 55555
ถ้าเป็นสาว ก็เลิกล้างลากันไป 5555 แต่เมียดันทนเราได้นี่สิ เลยอยู่กันยาวจนถีงป่านนี้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:37:01 By : Chaidhanan
 


 

No. 31

Guest


Quote:
ขี้เกียจอธิบายยาวเกิน เลยไปหามาให้
https://mystou.com/java-abstract-class/
แม้ไม่ใช้ c# แต่หลักการเหมือนกัน pascal ก็เหมือนกัน หลักการเขียน oop เหมือนกัน

ที่นี้ abstract class สามารถ สร้าง component แบบมีรูปได้
แต่ ผู้ที่จะ contain มัน ( parent class ) จะต้องมี รูป แค่ต้องกำหนด ให้มัน จะอยู่แบบลอยๆ ไม่ได้

เริ่มต้นคลาสแบบมีรูป อย่าทำแบบ abstract แบบง่ายที่สุดให้ inherit จาก component แบบมีรูป เช่น form หรือ panel

เมื่อก่อนผมก็คิดจะเขียน class component แบบมีรูป เอง อั๋ยยะ โคตรจะยุ่งยากเลย เอาวิธีง่ายๆ inherit เอาง่ายกว่าเยอะ



เมื่อก่อนผมก็เคยทำ และทำจนมากเกินไป

ทุกวันนี้ผมคิดใหม่ ทำแล้วต้องได้เงิน ถ้าทำแล้วไม่ได้เงิน มันก็เสียเวลาเปล่า

สถานะของผมทุกวันนี้ มันก็ไม่ต่างกับสุนัข คนมักจะเรียกผมว่า หมา
แต่ในบรรดาหมาด้วยกันเอง เขาเรียกผมว่า พี่หมา
+55555
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 11:47:38 By : หน้าฮี
 


 

No. 32

Guest


@TOR_CHEMISTRY

ผมคิดว่าคุณงง และหลายฯคพวกของคุณ (มึง) ก็งง
ผมเห็น Source Code นิดเดียว ทำไมผมถึงเข้าใจ

ระดับนี้แล้ว กวาดสายตาดูแป๊บ ก็รู้แล้ว ผมซื้อหวยไม่เคยถูก
แต่ผมเสี่ยงทาย โปรแกรมเมอร์ ไม่เคยผิด
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 12:01:53 By : หน้าฮี
 


 

No. 33

Guest


@Chaidhanan
ผมจริงฯเลยนะ วัยอายุของคุณ ทำไมหัวล้านวัยจัง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 12:20:11 By : หน้าฮี
 


 

No. 34

Guest


เอารูปพ่อมาลงหรือเปล่า? (ผมแค่สงสัย) +55555
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 12:22:18 By : หน้าฮี
 


 

No. 35



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



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

หลังจากงม คลาสมาซักพัก ก็พอมีหวังครับ

55




มันมาแล้ว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 12:25:16 By : lamaka.tor
 


 

No. 36

Guest


Quote:
https://www.youtube.com/watch?v=AQsqTzW4xS4

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 12:44:14 By : หน้าฮี
 


 

No. 37

Guest


@TOR_CHEMISTRY

เยี่ยม
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 12:45:35 By : หน้าฮี
 


 

No. 38



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


ตอบความคิดเห็นที่ : 33 เขียนโดย : หน้าฮี เมื่อวันที่ 2019-06-28 12:20:11
รายละเอียดของการตอบ ::
555555 รูปนี้ 5 ปีมาแล้ว แค่เถิกเล็กน้อย ผสม skin head เลยดูเหมือนมาก

มันสบายหัวดี และเอาแค่สบู่ฟอกก็สอาดแล้ว 5555
เมื่อก่อนผมยาวอยู่ เวลาทำงานชอบเอามือลูบหัวเสยผม มันเลยสกปรกง่าย เหม็นน่าลำคาญ สระก็ยาก
ผมเกิด 2503 ปีหน้าก็ 60 รับเงินเดือนรัฐได้ล่ะ 5555
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 12:51:13 By : Chaidhanan
 


 

No. 39



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



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

งานแล้วละกะถอนละคร้าบบบบบ 5555

https://www.youtube.com/watch?v=73Z6NVuNMd4

ยังเหลือแก้อีกบาน ยังไงก็อย่าเพิ่งพากันเบื่อเด้อ ครับ ท่าน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 13:02:18 By : lamaka.tor
 


 

No. 40



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



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

ผมละเกิด ไอเดีย จะเขียน control จาก ListControl เหมือน ComboBox
แต่ ผมจะเขียนเป็นรูปนี้

66


ถ้า เริ่มจาก ListControl เราจะเขียนให้มันมี ปุ่ม มี textbox แบบนี้ ได้ยังไงครับ


อ่อ.... ลืมอีกอย่างครับ
เราจะเอา internal class ของ .net มาใช้ได้ยังไง ครับ


ประวัติการแก้ไข
2019-06-28 17:02:09
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 17:01:06 By : lamaka.tor
 


 

No. 41

Guest


กระผมกราบ กระผมรับรู้ได้ นี่คืออาจารย์ของผม
กระผมขอบพระคุณมากครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 18:54:42 By : หน้าฮี
 


 

No. 42

Guest


หน้าฮีไม่เคยกราบใครง่ายฯ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 19:01:02 By : หน้าฮี
 


 

No. 43

Guest


Quote:
มันสบายหัวดี และเอาแค่สบู่ฟอกก็สอาดแล้ว 5555
เมื่อก่อนผมยาวอยู่ เวลาทำงานชอบเอามือลูบหัวเสยผม มันเลยสกปรกง่าย เหม็นน่าลำคาญ สระก็ยาก
ผมเกิด 2503 ปีหน้าก็ 60 รับเงินเดือนรัฐได้ล่ะ 5555


กระผมหน้าฮี กราบขอบคุณครับ (จากใจจริง)
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 19:11:47 By : หน้าฮี
 


 

No. 44

Guest


ผมเคยบอกแล้ว เด็กอายุุน้อยกว่า 50 ปี อย่ามาคุยกับผม
ยิ่งแก่ยิ่งอายุมากผมยิ่งชอบ ครับอาจารย์ของผม

+55555
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 19:18:03 By : หน้าฮี
 


 

No. 45

Guest


กะรผมหวังแต่เพียงว่า อาจารย์จะ กรุณาผม
(ไม่มีอะไรให้เราจดจำอีกแล้ว สำเร็จ/ล้มเหลว)
ไม่ต้องพะวง

ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 19:22:27 By : หน้าฮี
 


 

No. 46



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



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

ตอบความคิดเห็นที่ : 40 เขียนโดย : lamaka.tor เมื่อวันที่ 2019-06-28 17:01:06
รายละเอียดของการตอบ ::
inherit จาก panel หรือ usercontrol ก็ได้ตามสดวก
ผมชอบ panel จะกำหนดสีพื้น หรือขอบ หนาบาง หรือซ่อนก็ได้ ไม่ต้องมาสร้างเอง
แล้วจัดการเพิ่ม label textbox listbox button เอาเลยครับ อยากใส่อะไรก็ใส่ลงไป
จะเพิ่มจะลด property/method อะไรก็ว่าไป
จะอ้างตัวแปรจากภายนอกก็ เพิ่ม property / variable มารับค่า

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-28 20:49:58 By : NewbiePHP
 


 

No. 47



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



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

ตอบความคิดเห็นที่ : 46 เขียนโดย : NewbiePHP เมื่อวันที่ 2019-06-28 20:49:58
รายละเอียดของการตอบ ::
เอ่อ...


ที่ผมหมายถึง คือ สร้างจากคลาส ListControl ครับ
ตอนนี้ผมทำเป็น usercontrol อยู่

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-29 08:10:00 By : lamaka.tor
 


 

No. 48



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


ตอบความคิดเห็นที่ : 47 เขียนโดย : lamaka.tor เมื่อวันที่ 2019-06-29 08:10:00
รายละเอียดของการตอบ ::
จะเพิ่ม component ใน component ที่คนอื่นเขียนไว้ มันยากอยู่นะครับ ต้องรู้ว่า เขาวางอะไรไว้ตรงไหน เราจะขยับเขยือน ได้ไหม


และ ส่วนใหญ่เขา protected ไว้หมด ไปขยับขยายไม่ได้หรอกครับ
เราก็สร้าง usercontrol ขึ้นมาใหม่แล้วเอา component ที่มีอยู่ วางๆ เป็น ออปเจคใหม่ ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-29 09:21:03 By : Chaidhanan
 


 

No. 49



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



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

ตอบความคิดเห็นที่ : 48 เขียนโดย : Chaidhanan เมื่อวันที่ 2019-06-29 09:21:03
รายละเอียดของการตอบ ::
เมื่อวาน ผมลองสร้าง คลาสจาก ListControl
ขนาดยังไม่เอา textbox หรือ ปุ่มลง
ผมต้องเพิ่มโค้ด จาก .net เกือบ 10 กว่า ไฟล์ สุดท้ายเลยเลิกล้ม กลับมาแก้โค้ดเก่า ครับ


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-29 09:24:45 By : lamaka.tor
 


 

No. 50



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



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

โค้ดล่าสุดครับ เผื่อใครจะเอาไปใช้
Code (C#)
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Design;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using TORServices.ExtensionTor;
namespace TORServices.FormsTor
{
    [
    ComVisible(true),
    ClassInterface(ClassInterfaceType.AutoDispatch),
    LookupBindingProperties("DataSource", "DisplayMember", "ValueMember", "SelectedValue")
    ]
    public partial class Textbox2AndButton : UserControl
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnSearch = new System.Windows.Forms.Button();
            this.txtID = new System.Windows.Forms.TextBox();
            this.panel1 = new System.Windows.Forms.Panel();
            this.txtDetail = new System.Windows.Forms.TextBox();
            this.panel2 = new System.Windows.Forms.Panel();
            this.SuspendLayout();
            // 
            // btnSearch
            // 
            this.btnSearch.Dock = System.Windows.Forms.DockStyle.Right;
            this.btnSearch.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.btnSearch.Image = global::TORServices.Properties.Resources.search_button32x32;
            this.btnSearch.Location = new System.Drawing.Point(355, 0);
            this.btnSearch.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
            this.btnSearch.Name = "btnSearch";
            this.btnSearch.Size = new System.Drawing.Size(31, 31);
            this.btnSearch.TabIndex = 0;
            this.btnSearch.UseVisualStyleBackColor = true;
            this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
            // 
            // txtID
            // 
            this.txtID.Dock = System.Windows.Forms.DockStyle.Left;
            this.txtID.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.txtID.Location = new System.Drawing.Point(0, 0);
            this.txtID.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
            this.txtID.Name = "txtID";
            this.txtID.Size = new System.Drawing.Size(76, 29);
            this.txtID.TabIndex = 1;
            this.txtID.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtID_KeyDown);
            this.txtID.Leave += new System.EventHandler(this.txtID_Leave);
            // 
            // panel1
            // 
            this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
            this.panel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.panel1.Location = new System.Drawing.Point(76, 0);
            this.panel1.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(6, 31);
            this.panel1.TabIndex = 3;
            // 
            // txtDetail
            // 
            this.txtDetail.BackColor = System.Drawing.SystemColors.Window;
            this.txtDetail.Dock = System.Windows.Forms.DockStyle.Fill;
            this.txtDetail.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.txtDetail.Location = new System.Drawing.Point(82, 0);
            this.txtDetail.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
            this.txtDetail.Name = "txtDetail";
            this.txtDetail.ReadOnly = true;
            this.txtDetail.Size = new System.Drawing.Size(267, 29);
            this.txtDetail.TabIndex = 4;
            // 
            // panel2
            // 
            this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
            this.panel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.panel2.Location = new System.Drawing.Point(349, 0);
            this.panel2.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(6, 31);
            this.panel2.TabIndex = 5;
            // 
            // Textbox2AndButton
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.txtDetail);
            this.Controls.Add(this.panel2);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.txtID);
            this.Controls.Add(this.btnSearch);
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
            this.Name = "Textbox2AndButton";
            this.Size = new System.Drawing.Size(386, 31);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button btnSearch;
        private System.Windows.Forms.TextBox txtID;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.TextBox txtDetail;






        private DataTable tblSource;
        private string _DisplayMember;
        private string _ValueMember;
        private Panel panel2;
        private string stSelectedValue;
        public Textbox2AndButton()
        {
            InitializeComponent();

        }

        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("TextID")]
        public string TextID
        {
            get
            {
                return this.txtID.Text;
            }
            set
            {
                this.txtID.Text = value;
            }
        }
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("TextDetail")]
        public string TextDetail
        {
            get
            {
                return this.txtDetail.Text;
            }
            set
            {
                this.txtDetail.Text = value;
            }
        }

        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("ImageButton")]
        public Image ImageButton
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return btnSearch.Image;
            }
            set
            {
                btnSearch.Image = value; Invalidate();
            }
        }

        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("Color text ID")]
        public Color ColortextID
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return txtID.BackColor;
            }
            set
            {
                txtID.BackColor = value; Invalidate();
            }
        }
        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("Color text ID")]
        public Color ColortextDetail
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return txtDetail.BackColor;
            }
            set
            {
                txtDetail.BackColor = value; Invalidate();
            }
        }

        protected override void OnFontChanged(EventArgs e)
        {
            base.OnFontChanged(e);
            txtDetail.Font = Font;
            txtID.Font = Font;
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            this.Height = txtID.Height;
            btnSearch.Width = btnSearch.Height;
        }
        public event EventHandler TextBoxTextChanged
        {
            add
            {
                txtID.TextChanged += value;
            }
            remove
            {
                txtID.TextChanged -= value;
            }
        }
        public event EventHandler TextBoxDetailTextChanged
        {
            add
            {
                txtDetail.TextChanged += value;
            }
            remove
            {
                txtDetail.TextChanged -= value;
            }
        }
        [
          DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
          RefreshProperties(RefreshProperties.All),
          ParenthesizePropertyName(true)
          ]
        public ControlBindingsCollection DataBindings
        {
            get
            {
                ControlBindingsCollection bindings = (ControlBindingsCollection)this.txtID.DataBindings;
                if (bindings == null)
                {
                    bindings = new ControlBindingsCollection(this);
                }
                return bindings;
            }

        }

        private object dataSource;
        [
       DefaultValue(null),
       RefreshProperties(RefreshProperties.Repaint),
       AttributeProvider(typeof(IListSource))
       ]
        public object DataSource
        {
            get
            {
                return dataSource;
            }
            set
            {
                if (value != null && !(value is IList || value is IListSource))
                    throw new ArgumentException("SR.GetString(SR.BadDataSourceForComplexBinding)");
                if (dataSource == value)
                    return;
            }
        }

        /*  [Bindable(true)]
          [Category("Data")]
          [Description("Set DataSource")]
          public DataTable DataSource
          {
              get
              {
                  return tblSource;
              }
              set
              {
                  tblSource = value;
              }
          }*/

        [Category("Data")]
        [Editor(typeof(Textbox2AndButtonCaller), typeof(UITypeEditor))]
        [Description("Set field name in DisplayMember")]
        public string DisplayMember
        {
            get
            {
                return _DisplayMember;
            }
            set
            {
                _DisplayMember = value;
            }
        }

        [Category("Data")]
        [Editor(typeof(Textbox2AndButtonCaller), typeof(UITypeEditor))]
        [Description("Set field name in ValueMember")]
        public string ValueMember
        {
            get
            {
                return _ValueMember;
            }
            set
            {
                _ValueMember = value;
            }
        }
        [Browsable(false)]
        [DefaultValue("")]
        public string SelectedValue
        {
            get { return stSelectedValue; }
            set { stSelectedValue = value; }
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            Form parent = this.FindForm();
            Textbox2AndButtonChoseGrid popup = new Textbox2AndButtonChoseGrid(this);
            popup.Location = new Point(parent.Location.X + this.Location.X + 4, parent.Location.Y + this.Location.Y + this.Height + 30);

            popup.ShowDialog();

        }


        private void txtID_Leave(object sender, EventArgs e)
        {
            IDSearch();
        }

        private void IDSearch()
        {
            try
            {
                DataRow[] drs = tblSource.Select(ValueMember + " = " + txtID.Text);
                if (drs.Length >= 0)
                    txtDetail.Text = drs[0][DisplayMember].ToString();

            }
            catch { MessageBox.Show("Error! \n Data not found"); }

        }

        private void txtID_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                IDSearch();
        }
    }

    public class Textbox2AndButtonCaller : UITypeEditor
    {
        #region Variables declaration

        private IWindowsFormsEditorService edSvc = null;
        private ListBox cboTableNames = null;

        #endregion

        #region Override Methods

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context != null && context.Instance != null)
            {
                return UITypeEditorEditStyle.DropDown;
            }
            return base.GetEditStyle(context);
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                Textbox2AndButton control = (Textbox2AndButton)context.Instance;
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    cboTableNames = new ListBox();
                    cboTableNames.BorderStyle = BorderStyle.FixedSingle;
                    DataTable tbl = control.DataSource as DataTable;
                    for (int i = 0; i < tbl.Columns.Count; i++)
                        cboTableNames.Items.Add(tbl.Columns[i].ColumnName);
                    /* for (int i = 0; i < control.DataSource.Columns.Count; i++)
                         cboTableNames.Items.Add(control.DataSource.Columns[i].ColumnName);*/

                    cboTableNames.SelectedIndexChanged += new EventHandler(cboTableNames_SelectedIndexChanged);
                    edSvc.DropDownControl(cboTableNames);
                    return cboTableNames.SelectedItem;
                }
            }
            return base.EditValue(context, provider, value);
        }

        #endregion

        #region Events

        private void cboTableNames_SelectedIndexChanged(object sender, EventArgs e)
        {
            cboTableNames.Text = (string)cboTableNames.SelectedItem;
            edSvc.CloseDropDown();
        }

        #endregion
    }
}



เป็นเรื่องที่น่าขันมาก ผมนั่งแก้เป็นวัน แต่สุดท้ายมันก็แก้จาก โค้ด เดิมนิดเดียว
แค่
เปลี่ยนจาก

1311

ซึ่งเป็นโค้ดเดิมของคำถาม มาเป็น

333

แก้แค่เนี๊ยะ นั่งทั้งวัน 5555

1312

6665

คลิกแล้ว BindingSource / Dataset/TableAdapter มาเหมือน combobox เด๊ะๆ
แล้วก็เพิ่มโค้ด Fill เหมือน combobox เด๊ะๆ อีกเช่นกัน

ชอบใจมากกกก

แต่มันก็ยังติดอยู่อีกนั่นแหละครับ
พอเปลี่ยน DataSource จาก DataTable มาเป็น object
ปรากฎว่า โค้ดในการ สร้าง ListBox ของพวก DisplayMember และ ValueMember มีปัญหาคือมันไม่ขึ้นมาครับ

ตอนนี้ ขอความกรุณา ขอวิธี convert object to DataTable หรือ ดึง List ออกมาจาก object ที่เป็น DataSource ทีครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-29 09:36:52 By : lamaka.tor
 


 

No. 51



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



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

ตอนนี้แก้ ปัญหา เรียบร้อยแล้วครับ
โค้ดสมบูรณ์ ครับ แต่ขาดโค้ด popup นะครับ ใครอยากได้เดี๋ยวเอามาลงให้ครับ

Code (C#)
namespace TORServices.FormsTor
{
    [
    ComVisible(true),
    ClassInterface(ClassInterfaceType.AutoDispatch),
    LookupBindingProperties("DataSource", "DisplayMember", "ValueMember", "SelectedValue")
    ]
    public partial class Text2BoxButton : UserControl
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.txtDetail = new System.Windows.Forms.TextBox();
            this.panel2 = new System.Windows.Forms.Panel();
            this.panel1 = new System.Windows.Forms.Panel();
            this.txtID = new System.Windows.Forms.TextBox();
            this.btnSearch = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // txtDetail
            // 
            this.txtDetail.BackColor = System.Drawing.SystemColors.Window;
            this.txtDetail.Dock = System.Windows.Forms.DockStyle.Fill;
            this.txtDetail.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.txtDetail.Location = new System.Drawing.Point(141, 0);
            this.txtDetail.Margin = new System.Windows.Forms.Padding(7);
            this.txtDetail.Name = "txtDetail";
            this.txtDetail.ReadOnly = true;
            this.txtDetail.Size = new System.Drawing.Size(310, 29);
            this.txtDetail.TabIndex = 9;
            // 
            // panel2
            // 
            this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
            this.panel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.panel2.Location = new System.Drawing.Point(451, 0);
            this.panel2.Margin = new System.Windows.Forms.Padding(7);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(16, 31);
            this.panel2.TabIndex = 10;
            // 
            // panel1
            // 
            this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
            this.panel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.panel1.Location = new System.Drawing.Point(121, 0);
            this.panel1.Margin = new System.Windows.Forms.Padding(7);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(20, 31);
            this.panel1.TabIndex = 8;
            // 
            // txtID
            // 
            this.txtID.Dock = System.Windows.Forms.DockStyle.Left;
            this.txtID.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.txtID.Location = new System.Drawing.Point(0, 0);
            this.txtID.Margin = new System.Windows.Forms.Padding(7);
            this.txtID.Name = "txtID";
            this.txtID.Size = new System.Drawing.Size(121, 29);
            this.txtID.TabIndex = 7;
            // 
            // btnSearch
            // 
            this.btnSearch.Dock = System.Windows.Forms.DockStyle.Right;
            this.btnSearch.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.btnSearch.Image = global::TORServices.Properties.Resources.search32x32;
            this.btnSearch.Location = new System.Drawing.Point(467, 0);
            this.btnSearch.Margin = new System.Windows.Forms.Padding(7);
            this.btnSearch.Name = "btnSearch";
            this.btnSearch.Size = new System.Drawing.Size(37, 31);
            this.btnSearch.TabIndex = 6;
            this.btnSearch.UseVisualStyleBackColor = true;
            // 
            // Text2BoxButton
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.txtDetail);
            this.Controls.Add(this.panel2);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.txtID);
            this.Controls.Add(this.btnSearch);
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.Margin = new System.Windows.Forms.Padding(6);
            this.Name = "Text2BoxButton";
            this.Size = new System.Drawing.Size(504, 31);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.TextBox txtDetail;
        private System.Windows.Forms.Panel panel2;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.TextBox txtID;
        private System.Windows.Forms.Button btnSearch;

        public Text2BoxButton()
        {
            InitializeComponent();
            this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
            this.txtID.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtID_KeyDown);
            this.txtID.Leave += new System.EventHandler(this.txtID_Leave);
        }

        #region _databinding
        private static readonly object EVENT_DATASOURCECHANGED = new object();
        private static readonly object EVENT_DISPLAYMEMBERCHANGED = new object();
        private static readonly object EVENT_VALUEMEMBERCHANGED = new object();
        private static readonly object EVENT_SELECTEDVALUECHANGED = new object();
        private static readonly object EVENT_FORMATINFOCHANGED = new object();
        private static readonly object EVENT_FORMATSTRINGCHANGED = new object();
        private static readonly object EVENT_FORMATTINGENABLEDCHANGED = new object();


        private object dataSource;
        private CurrencyManager dataManager;
        private BindingMemberInfo displayMember;
        private BindingMemberInfo valueMember;

        // Formatting stuff
        private string formatString = String.Empty;
        private static readonly object EVENT_FORMAT = new object();
        private TypeConverter displayMemberConverter = null;


        private bool isDataSourceInitialized;
        private bool isDataSourceInitEventHooked;
        private bool inSetDataConnection = false;

        [
        DefaultValue(null),
        RefreshProperties(RefreshProperties.Repaint),
        AttributeProvider(typeof(IListSource))
        ]
        public object DataSource
        {
            get
            {
                return dataSource;
            }
            set
            {
                if (value != null && !(value is IList || value is IListSource))
                    throw new ArgumentException("SR.GetString(SR.BadDataSourceForComplexBinding)");
                if (dataSource == value)
                    return;
                // When we change the dataSource to null, we should reset
                // the displayMember to "". See ASURT 85662.
                try
                {
                    SetDataConnection(value, displayMember, false);
                    
                }
                catch
                {

                    DisplayMember = "";
                }
                if (value == null)
                    DisplayMember = "";
            }
        }
        public event EventHandler DataSourceChanged
        {
            add
            {
                Events.AddHandler(EVENT_DATASOURCECHANGED, value);
            }
            remove
            {
                Events.RemoveHandler(EVENT_DATASOURCECHANGED, value);
            }
        }

        /// <include file='doc\ListControl.uex' path='docs/doc[@for="ListControl.DataManager"]/*' />
        protected CurrencyManager DataManager
        {
            get
            {
                return this.dataManager;
            }
        }


        [
        DefaultValue(""),
        TypeConverterAttribute("System.Windows.Forms.Design.DataMemberFieldConverter"),
        Editor("System.Windows.Forms.Design.DataMemberFieldEditor", typeof(System.Drawing.Design.UITypeEditor))
        ]
        public string DisplayMember
        {
            get
            {
                return displayMember.BindingMember;
            }
            set
            {
                BindingMemberInfo oldDisplayMember = displayMember;
                try
                {
                    SetDataConnection(dataSource, new BindingMemberInfo(value), false);
                }
                catch
                {
                    displayMember = oldDisplayMember;
                }
            }
        }

        public event EventHandler DisplayMemberChanged
        {
            add
            {
                Events.AddHandler(EVENT_DISPLAYMEMBERCHANGED, value);
            }
            remove
            {
                Events.RemoveHandler(EVENT_DISPLAYMEMBERCHANGED, value);
            }
        }

        // Cached type converter of the property associated with the display member
        private TypeConverter DisplayMemberConverter
        {
            get
            {
                if (this.displayMemberConverter == null &&
                    this.DataManager != null &&
                    this.displayMember != null)
                {
                    PropertyDescriptorCollection props = this.DataManager.GetItemProperties();
                    if (props != null)
                    {
                        PropertyDescriptor displayMemberProperty = props.Find(this.displayMember.BindingField, true);
                        if (displayMemberProperty != null)
                        {
                            this.displayMemberConverter = displayMemberProperty.Converter;
                        }
                    }
                }
                return this.displayMemberConverter;
            }
        }

    
        private bool BindingMemberInfoInDataManager(BindingMemberInfo bindingMemberInfo)
        {
            if (dataManager == null)
                return false;
            PropertyDescriptorCollection props = dataManager.GetItemProperties();
            int propsCount = props.Count;

            for (int i = 0; i < propsCount; i++)
            {
                if (typeof(IList).IsAssignableFrom(props[i].PropertyType))
                    continue;
                if (props[i].Name.Equals(bindingMemberInfo.BindingField))
                {
                    return true;
                }
            }

            for (int i = 0; i < propsCount; i++)
            {
                if (typeof(IList).IsAssignableFrom(props[i].PropertyType))
                    continue;
                if (String.Compare(props[i].Name, bindingMemberInfo.BindingField, true, CultureInfo.CurrentCulture) == 0)
                {
                    return true;
                }
            }

            return false;
        }


        [
        DefaultValue(""),
        Editor("System.Windows.Forms.Design.DataMemberFieldEditor", typeof(System.Drawing.Design.UITypeEditor))
        ]
        public string ValueMember
        {
            get
            {
                return valueMember.BindingMember;
            }
            set
            {
                if (value == null)
                    value = "";
                BindingMemberInfo newValueMember = new BindingMemberInfo(value);
                BindingMemberInfo oldValueMember = valueMember;
                if (!newValueMember.Equals(valueMember))
                {
                    // If the displayMember is set to the EmptyString, then recreate the dataConnection
                    //
                    if (DisplayMember.Length == 0)
                        SetDataConnection(DataSource, newValueMember, false);
                    // See if the valueMember is a member of 
                    // the properties in the dataManager
                    if (this.dataManager != null && value != null && value.Length != 0)
                        if (!BindingMemberInfoInDataManager(newValueMember))
                        {
                            throw new ArgumentException("SR.GetString(SR.ListControlWrongValueMember), value");
                        }

                    valueMember = newValueMember;
                    OnValueMemberChanged(EventArgs.Empty);
                    OnSelectedValueChanged(EventArgs.Empty);
                }
            }
        }


        public event EventHandler ValueMemberChanged
        {
            add
            {
                Events.AddHandler(EVENT_VALUEMEMBERCHANGED, value);
            }
            remove
            {
                Events.RemoveHandler(EVENT_VALUEMEMBERCHANGED, value);
            }
        }


        protected virtual bool AllowSelection
        {
            get
            {
                return true;
            }
        }


        public  int SelectedIndex
        {
            get;
            set;
        }
       
        private string stSelectedValue;
        [Browsable(false)]
        [DefaultValue("")]
        public string SelectedValue
        {
            get { return stSelectedValue; }
            set { stSelectedValue = value; }
        }

        protected object FilterItemOnProperty(object item)
        {
            return FilterItemOnProperty(item, displayMember.BindingField);
        }


        protected object FilterItemOnProperty(object item, string field)
        {
            if (item != null && field.Length > 0)
            {
                try
                {
                    // if we have a dataSource, then use that to display the string
                    PropertyDescriptor descriptor;
                    if (this.dataManager != null)
                        descriptor = this.dataManager.GetItemProperties().Find(field, true);
                    else
                        descriptor = TypeDescriptor.GetProperties(item).Find(field, true);
                    if (descriptor != null)
                    {
                        item = descriptor.GetValue(item);
                    }
                }
                catch
                {
                }
            }
            return item;
        }

        protected virtual void OnDataSourceChanged(EventArgs e)
        {
            EventHandler eh = Events[EVENT_DATASOURCECHANGED] as EventHandler;
            if (eh != null)
            {
                eh(this, e);
            }
        }


        protected virtual void OnDisplayMemberChanged(EventArgs e)
        {
            EventHandler eh = Events[EVENT_DISPLAYMEMBERCHANGED] as EventHandler;
            if (eh != null)
            {
                eh(this, e);
            }
        }

       
        protected virtual void OnValueMemberChanged(EventArgs e)
        {
            EventHandler eh = Events[EVENT_VALUEMEMBERCHANGED] as EventHandler;
            if (eh != null)
            {
                eh(this, e);
            }
        }


        protected virtual void OnSelectedValueChanged(EventArgs e)
        {
            EventHandler eh = Events[EVENT_SELECTEDVALUECHANGED] as EventHandler;
            if (eh != null)
            {
                eh(this, e);
            }
        }

        private void DataSourceDisposed(object sender, EventArgs e)
        {
            Debug.Assert(sender == this.dataSource, "how can we get dispose notification for anything other than our dataSource?");
            SetDataConnection(null, new BindingMemberInfo(""), true);
        }

        private void DataSourceInitialized(object sender, EventArgs e)
        {
            ISupportInitializeNotification dsInit = (this.dataSource as ISupportInitializeNotification);
            Debug.Assert(dsInit != null, "Text2BoxButton: ISupportInitializeNotification.Initialized event received, but current DataSource does not support ISupportInitializeNotification!");
            Debug.Assert(dsInit.IsInitialized, "Text2BoxButton: DataSource sent ISupportInitializeNotification.Initialized event but before it had finished initializing.");
            SetDataConnection(this.dataSource, this.displayMember, true);
        }

        private void SetDataConnection(object newDataSource, BindingMemberInfo newDisplayMember, bool force)
        {
            bool dataSourceChanged = dataSource != newDataSource;
            bool displayMemberChanged = !displayMember.Equals(newDisplayMember);

            if (inSetDataConnection)
            {
                return;
            }
            try
            {
                if (force || dataSourceChanged || displayMemberChanged)
                {
                    inSetDataConnection = true;
                    IList currentList = this.DataManager != null ? this.DataManager.List : null;
                    bool currentManagerIsNull = this.DataManager == null;

                    UnwireDataSource();

                    dataSource = newDataSource;
                    displayMember = newDisplayMember;

                    WireDataSource();

                    if (isDataSourceInitialized)
                    {

                        CurrencyManager newDataManager = null;
                        if (newDataSource != null && BindingContext != null && !(newDataSource == Convert.DBNull))
                        {
                            newDataManager = (CurrencyManager)BindingContext[newDataSource, newDisplayMember.BindingPath];
                        }


                        if (dataManager != null && (displayMemberChanged || dataSourceChanged) && displayMember.BindingMember != null && displayMember.BindingMember.Length != 0)
                        {

                            if (!BindingMemberInfoInDataManager(displayMember))
                                throw new ArgumentException("SR.GetString(SR.ListControlWrongDisplayMember), newDisplayMember");
                        }
                    }
                    this.displayMemberConverter = null;
                }

                if (dataSourceChanged)
                {
                    OnDataSourceChanged(EventArgs.Empty);
                }

                if (displayMemberChanged)
                {
                    OnDisplayMemberChanged(EventArgs.Empty);
                }
            }
            finally
            {
                inSetDataConnection = false;
            }
        }

        private void UnwireDataSource()
        {
            // If the source is a component, then unhook the Disposed event
            if (this.dataSource is IComponent)
            {
                ((IComponent)this.dataSource).Disposed -= new EventHandler(DataSourceDisposed);
            }

            ISupportInitializeNotification dsInit = (this.dataSource as ISupportInitializeNotification);

            if (dsInit != null && isDataSourceInitEventHooked)
            {
                dsInit.Initialized -= new EventHandler(DataSourceInitialized);
                isDataSourceInitEventHooked = false;
            }
        }

        private void WireDataSource()
        {
            if (this.dataSource is IComponent)
            {
                ((IComponent)this.dataSource).Disposed += new EventHandler(DataSourceDisposed);
            }

            ISupportInitializeNotification dsInit = (this.dataSource as ISupportInitializeNotification);

            if (dsInit != null && !dsInit.IsInitialized)
            {
                dsInit.Initialized += new EventHandler(DataSourceInitialized);
                isDataSourceInitEventHooked = true;
                isDataSourceInitialized = false;
            }
            else
            {
                isDataSourceInitialized = true;
            }
        }

        partial  void SetItemsCore(IList items);
        protected virtual void SetItemCore(int index, object value) { }

        #endregion

        #region Textbox
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("TextID")]
        public string TextID
        {
            get
            {
                return this.txtID.Text;
            }
            set
            {
                this.txtID.Text = value;
            }
        }
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("TextDetail")]
        public string TextDetail
        {
            get
            {
                return this.txtDetail.Text;
            }
            set
            {
                this.txtDetail.Text = value;
            }
        }

        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("ImageButton")]
        public Image ImageButton
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return btnSearch.Image;
            }
            set
            {
                btnSearch.Image = value; Invalidate();
            }
        }

        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("Color text ID")]
        public Color ColortextID
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return txtID.BackColor;
            }
            set
            {
                txtID.BackColor = value; Invalidate();
            }
        }
        [Localizable(true)]
        [System.ComponentModel.Browsable(true)]
        [System.ComponentModel.Category("TOR Setting")]
        [System.ComponentModel.Description("Color text ID")]
        public Color ColortextDetail
        {
            [ResourceExposure(ResourceScope.Machine)]
            [ResourceConsumption(ResourceScope.Machine)]
            get
            {
                return txtDetail.BackColor;
            }
            set
            {
                txtDetail.BackColor = value; Invalidate();
            }
        }

        protected override void OnFontChanged(EventArgs e)
        {
            base.OnFontChanged(e);
            txtDetail.Font = Font;
            txtID.Font = Font;
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            this.Height = txtID.Height;
            btnSearch.Width = btnSearch.Height;
        }
        public event EventHandler TextBoxTextChanged
        {
            add
            {
                txtID.TextChanged += value;
            }
            remove
            {
                txtID.TextChanged -= value;
            }
        }
        public event EventHandler TextBoxDetailTextChanged
        {
            add
            {
                txtDetail.TextChanged += value;
            }
            remove
            {
                txtDetail.TextChanged -= value;
            }
        }
        [
          DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
          RefreshProperties(RefreshProperties.All),
          ParenthesizePropertyName(true)
          ]
        public ControlBindingsCollection DataBindings
        {
            get
            {
                ControlBindingsCollection bindings = (ControlBindingsCollection)this.txtID.DataBindings;
                if (bindings == null)
                {
                    bindings = new ControlBindingsCollection(this);
                }
                return bindings;
            }

        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            Form parent = this.FindForm();
            Text2ButtonChoseGrid popup = new  Text2ButtonChoseGrid(this);
            popup.Location = new Point(parent.Location.X + this.Location.X + 4, parent.Location.Y + this.Location.Y + this.Height + 30);

            popup.ShowDialog();

        }


        private void txtID_Leave(object sender, EventArgs e)
        {
            IDSearch();
        }

        private void IDSearch()
        {
            try
            {
                BindingSource lst = (BindingSource)dataSource ;
                 DataRow[] drs = lst.ToDataTable().Select(ValueMember + " = " + txtID.Text);
              
                if (drs.Length >= 0)
                    txtDetail.Text = drs[0][DisplayMember].ToString();

            }
            catch { MessageBox.Show("Error! \n Data not found"); }

        }

        private void txtID_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                IDSearch();
        }
        #endregion
    }
}


ได้ตามต้องการเด๊ะๆ
1

2

3

4


ตัว BindingSource ก็เรียบร้อยแล้ว
กะว่าจะแก้ Popup ให้มันสวยๆ หน่อย ก็น่าจะใช้ได้แล้วครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-29 16:36:00 By : lamaka.tor
 


 

No. 52



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


ตอบความคิดเห็นที่ : 51 เขียนโดย : lamaka.tor เมื่อวันที่ 2019-06-29 16:36:00
รายละเอียดของการตอบ ::
แจ่ม


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-29 17:02:53 By : Chaidhanan
 


 

No. 53



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



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

โค้ด Popup นะครับ

https://www.codeproject.com/Articles/17502/Simple-Popup-Control
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-29 17:23:33 By : lamaka.tor
 


 

No. 54



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



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

ไหนๆงานก็เสร็จไปเปราะหนึ่งแล้ว

เรามาดูหนัง R 18+ กันดีกว่า

https://www.youtube.com/watch?v=F4PRDOw7Fhg

เด็กอายุไม่ถึง 80 พ่อแม่ควรให้คำแนะนำนะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-29 21:21:35 By : lamaka.tor
 


 

No. 55



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


ตอบความคิดเห็นที่ : 54 เขียนโดย : lamaka.tor เมื่อวันที่ 2019-06-29 21:21:35
รายละเอียดของการตอบ ::


ยังไม่อยากตามไปรับคำแนะนำบนสวรรค์ 5555
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2019-06-30 08:05:10 By : Chaidhanan
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : WinApp C# มาอีกแล้ว ครับ ปัญหา รอบดึก เกี่ยวกับ การเขียน User control ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

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