반응형
KnownColor[] colors  = Enum.GetValues(typeof(KnownColor)); 
foreach(KnownColor knowColor in colors) 
{ 
  Color color = Color.FromKnownColor(knowColor); 
} 
반응형
  
public class ListViewWithComboBox : ListView
        {
            //Field
            ComboBox _comboBox;
            ListViewItem.ListViewSubItem item;

            //properties
            public ComboBox ComBoBox
            {
                get { return _comboBox; }
                set { _comboBox = value; }
            }

            //Constructor
            public ListViewWithComboBox()
                : base()
            {
                ComBoBox = new ComboBox();

                //콤보박스에 값을 셋팅해준다


                ComBoBox.LostFocus += new EventHandler(ComBoBox_LostFocus);
                ComBoBox.SelectedValueChanged += new EventHandler(ComBoBox_SelectedValueChanged);
                
            }

            //public Method
            public void showComboBox()
            {

                 item =  this.SelectedItems[0].SubItems[1];
                _comboBox.Location = item.Bounds.Location;
                _comboBox.Size = item.Bounds.Size;

                _comboBox.SelectedValueChanged -= new EventHandler(ComBoBox_SelectedValueChanged);
                _comboBox.Text = item.Text;
                _comboBox.SelectedValueChanged += new EventHandler(ComBoBox_SelectedValueChanged);
                this.Controls.Add(_comboBox);
                _comboBox.Focus();
            }

            //Event
            void ComBoBox_SelectedValueChanged(object sender, EventArgs e)
            {
                ComboBox combobox = sender as ComboBox;

                //ListView의 Item에 값을 셋팅한다.



                item.Text =  combobox.SelectedItem.ToString();
                 this.Controls.Remove(ComBoBox);
            }

            void ComBoBox_LostFocus(object sender, EventArgs e)
            {
                this.Controls.Remove(_comboBox);
            }


        }
반응형
        private Image Base64ToImage(string base64String)
        {
            // Convert Base64 String to byte[]
            byte[] imageBytes = Convert.FromBase64String(base64String);
            MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);

            // Convert byte[] to Image
            ms.Write(imageBytes, 0, imageBytes.Length);
            Image image = Image.FromStream(ms, true);
            return image;
        }
반응형
 

       private void MainForm_DragDrop(object sender, DragEventArgs e)
        {

            // transfer the filenames to a string array
            // (yes, everything to the left of the "=" can be put in the 
            // foreach loop in place of "files", but this is easier to understand.)
            if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
            {

                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

                foreach (string item in files)
                {
                    OpenFile(item);

                }
            }
        }





        private void MainForm_DragEnter(object sender, DragEventArgs e)
        {
            // make sure they're actually dropping files (not text or anything else)
            if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
                // allow them to continue
                // (without this, the cursor stays a "NO" symbol
                e.Effect = DragDropEffects.All;
        }

+ Recent posts