How can I drag file names from Windows Explorer and drop them into a listbox
Place a ListBox on your form, set its AllowDrop property and handle both DragEnter and DragDrop as below. private void listBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.All; else e.Effect = DragDropEffects.None; } private void listBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { string[] files = (string[])e.Data.GetData(‘FileDrop’, false); foreach (string s in files) { //just filename listBox1.Items.Add(s.Substring(1 + s.LastIndexOf(@’\’))); //or fullpathname // listBox1.Items.Add(s); } }
How come I don’t get to see the full call stack while debugging in VS2003?
In VS2003, debug info for unmanaged code is turned off by default. This is why you will not see the call stack including code in the System dlls. To enable debugging for unmanaged code go to your project properties dialog and turn on as shown in the image below: Fig: Turning On Unmanaged code debugging
How can I make a control occupy all the client area of a form
private void Form1_Load(object sender, System.EventArgs e) { Bitmap newBmp = new Bitmap(100, 100); Graphics g = Graphics.FromImage(newBmp); g.FillRectangle(new SolidBrush(Color.Red), 0, 0, 33, 100); g.FillRectangle(new SolidBrush(Color.White), 34, 0, 33, 100); g.FillRectangle(new SolidBrush(Color.Blue), 68, 0, 33, 100); pictureBox1.Image = newBmp; //pictureBox1 was dropped on the form }
How do I prevent a click into the grid highlighting a cell
Set the grid’s Enabled property to false. dataGrid1.Enabled = false;
How do I implement an owner drawn combobox
You can subclass ComboBox. In your derived class, make sure you set this.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; this.DropDownStyle = ComboBoxStyle.DropDownList; You also need to handle the DrawItem event to actually implement the drawing. Check out the details in the OwnerDrawnComboBox sample.