Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: Frames in axWebBrowser control Pin
Andrlage9-Sep-03 11:54
Andrlage9-Sep-03 11:54 
GeneralRe: Frames in axWebBrowser control Pin
Arun Chembilath30-Apr-11 7:10
Arun Chembilath30-Apr-11 7:10 
GeneralDLL import and parameters Pin
gmar9-Sep-03 0:56
gmar9-Sep-03 0:56 
GeneralRe: DLL import and parameters Pin
Jagadeesh VN9-Sep-03 3:49
Jagadeesh VN9-Sep-03 3:49 
GeneralDragDrop registration failed Pin
Nick Seng8-Sep-03 18:24
Nick Seng8-Sep-03 18:24 
Generalusing activex/com listeners (callbacks) Pin
olivier.fillon@csiro.au8-Sep-03 15:47
olivier.fillon@csiro.au8-Sep-03 15:47 
GeneralRe: I have problem to drop image files to PictureBox control... Pin
Nick Parker8-Sep-03 15:38
protectorNick Parker8-Sep-03 15:38 
GeneralRe: I have problem to drop image files to PictureBox control... Pin
Donald_a9-Sep-03 3:36
Donald_a9-Sep-03 3:36 
This should do what you need:

private void Form1_Load(object sender, System.EventArgs e)
{
    //This is vital - tells the picturebox to accept dragdrop notifications
    //For some reason it does not seem to appear in intellisense or the Visual Studio designer.
    //It does build though!!
    this.pictureBox1.AllowDrop = true;
}

private void pictureBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
    //Make sure item being dropped is a file
    if (e.Data.GetDataPresent(DataFormats.FileDrop))
    {
        e.Effect = DragDropEffects.All;
    }
    else//Otherwise do not allow drop
    {
        e.Effect = DragDropEffects.None;
    }
}

private void pictureBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
    //Get an array of strings - needs an array because the user can drag more than one item
    //into the picturebox
    string[] itemsInDrop = (string[])e.Data.GetData("FileDrop", false);

    //loop over the strings
    foreach (string path in itemsInDrop)
    {
        //Do what you want here.
        //I check the iamge exists then try to load it into the picturebox.
        //This is obviously a bit pointless for more than one image, but acts as an example.
        //NB System.ArgumentException is thrown when you try to instantiate a bitmap object
        //with an invalid file path.
        FileInfo CheckForImage = new FileInfo(path);

        if(!CheckForImage.Exists)
        {return;}

        try
        {
            Bitmap newImage = new Bitmap(path);
            this.pictureBox1.Image = newImage;
        }
        catch(System.ArgumentException)
        {
            MessageBox.Show("The file at " + path + " is not a valid image.", "Invalid Image", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}

GeneralStatus Bar with Custom Panels Pin
Clarke768-Sep-03 14:12
Clarke768-Sep-03 14:12 
GeneralGet window content as bitmap Pin
sumeat8-Sep-03 14:10
sumeat8-Sep-03 14:10 
GeneralRe: Get window content as bitmap Pin
azusakt8-Sep-03 15:36
azusakt8-Sep-03 15:36 
Generaltcpclient stream read Pin
mikemilano8-Sep-03 13:12
mikemilano8-Sep-03 13:12 
GeneralRe: tcpclient stream read Pin
leppie8-Sep-03 16:05
leppie8-Sep-03 16:05 
GeneralRe: tcpclient stream read Pin
leppie8-Sep-03 16:05
leppie8-Sep-03 16:05 
GeneralRe: tcpclient stream read Pin
Nick Parker8-Sep-03 16:25
protectorNick Parker8-Sep-03 16:25 
GeneralRe: tcpclient stream read Pin
TimK8-Sep-03 16:19
TimK8-Sep-03 16:19 
GeneralExtand and access the internat Microsoft Office object structure Pin
gicio8-Sep-03 9:47
gicio8-Sep-03 9:47 
GeneralJust a detailed question Pin
jphuphilly8-Sep-03 9:28
jphuphilly8-Sep-03 9:28 
GeneralRe: Just a detailed question Pin
leppie8-Sep-03 10:50
leppie8-Sep-03 10:50 
Questionwhat is the difference between [,] & [][]? Pin
yyf8-Sep-03 8:32
yyf8-Sep-03 8:32 
AnswerRe: what is the difference between [,] & [][]? Pin
David Stone8-Sep-03 9:06
sitebuilderDavid Stone8-Sep-03 9:06 
GeneralRe: what is the difference between [,] & [][]? Pin
Anonymous12-Sep-03 6:09
Anonymous12-Sep-03 6:09 
QuestionHow to realloc? Pin
yyf8-Sep-03 8:30
yyf8-Sep-03 8:30 
AnswerRe: How to realloc? Pin
Daniel Turini8-Sep-03 9:18
Daniel Turini8-Sep-03 9:18 
AnswerRe: How to realloc? Pin
Nemanja Trifunovic8-Sep-03 9:30
Nemanja Trifunovic8-Sep-03 9:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.