Click here to Skip to main content
15,881,709 members
Home / Discussions / C#
   

C#

 
QuestionCreating a struct dynamically Pin
Member 1452625729-Jul-19 21:48
Member 1452625729-Jul-19 21:48 
AnswerRe: Creating a struct dynamically Pin
OriginalGriff29-Jul-19 22:06
mveOriginalGriff29-Jul-19 22:06 
AnswerRe: Creating a struct dynamically Pin
BillWoodruff31-Jul-19 14:28
professionalBillWoodruff31-Jul-19 14:28 
SuggestionRe: Creating a struct dynamically Pin
Richard Deeming1-Aug-19 1:40
mveRichard Deeming1-Aug-19 1:40 
GeneralRe: Creating a struct dynamically Pin
BillWoodruff1-Aug-19 8:47
professionalBillWoodruff1-Aug-19 8:47 
QuestionError when i try to add my control to form1 Pin
_Q12_29-Jul-19 8:30
_Q12_29-Jul-19 8:30 
AnswerRe: Error when i try to add my control to form1 Pin
Richard Deeming29-Jul-19 9:10
mveRichard Deeming29-Jul-19 9:10 
GeneralRe: Error when i try to add my control to form1 Pin
_Q12_29-Jul-19 10:10
_Q12_29-Jul-19 10:10 
___The bug is thrown at the initialization of the image. As you can see in the code below:
public tab()
{
    InitializeComponent();
}


Image img = new Bitmap(@"google.png");
Rectangle rect = new Rectangle(5, 5, 22, 22);

private void tab_Paint(object sender, PaintEventArgs e)
{
    e.Graphics.DrawImage(img, rect);
}


___ NEXT, i initialize it in the constructor, following your helping code like this:
public partial class tab : UserControl
{
    public tab()
    {
        InitializeComponent();
        if (!DesignMode && File.Exists("google.png"))
        {
            img = new Bitmap("google.png");
        }
    }


    Image img;
    Rectangle rect = new Rectangle(5, 5, 22, 22);

    private void tab_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.DrawImage(img, rect);
    }


but another Error appear:
https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/281c49f0-e874-4b83-bff6-9bc6b8526d42/ddctlq3-8c112b8d-5685-4a43-a96e-21046443ef9a.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzI4MWM0OWYwLWU4NzQtNGI4My1iZmY2LTliYzZiODUyNmQ0MlwvZGRjdGxxMy04YzExMmI4ZC01Njg1LTRhNDMtYTk2ZS0yMTA0NjQ0M2VmOWEuanBnIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.1fkgpeEVDKRy30I70lftNt0WfbpoFl8LACty1N_fzsc[^]

Now what?
_ Your '!DesignMode' solution, is really nice and i didnt know it at all !
Awesome so far.
GeneralRe: Error when i try to add my control to form1 Pin
Richard Deeming30-Jul-19 1:52
mveRichard Deeming30-Jul-19 1:52 
GeneralRe: Error when i try to add my control to form1 Pin
_Q12_30-Jul-19 7:58
_Q12_30-Jul-19 7:58 
GeneralRe: Error when i try to add my control to form1 Pin
_Q12_29-Jul-19 10:34
_Q12_29-Jul-19 10:34 
GeneralRe: Error when i try to add my control to form1 Pin
_Q12_29-Jul-19 22:10
_Q12_29-Jul-19 22:10 
AnswerRe: Error when i try to add my control to form1 Pin
Dave Kreskowiak29-Jul-19 9:16
mveDave Kreskowiak29-Jul-19 9:16 
QuestionUnauthorizedAccessException Access to the remote share path Pin
Member 1158435626-Jul-19 0:09
Member 1158435626-Jul-19 0:09 
AnswerRe: UnauthorizedAccessException Access to the remote share path Pin
#realJSOP26-Jul-19 0:44
mve#realJSOP26-Jul-19 0:44 
Questionc# app design Pin
Member 1454172825-Jul-19 13:31
Member 1454172825-Jul-19 13:31 
AnswerRe: c# app design Pin
Gerry Schmitz25-Jul-19 14:42
mveGerry Schmitz25-Jul-19 14:42 
AnswerRe: c# app design Pin
Mycroft Holmes25-Jul-19 14:43
professionalMycroft Holmes25-Jul-19 14:43 
GeneralRe: c# app design Pin
#realJSOP26-Jul-19 0:47
mve#realJSOP26-Jul-19 0:47 
GeneralRe: c# app design Pin
Mycroft Holmes26-Jul-19 11:52
professionalMycroft Holmes26-Jul-19 11:52 
GeneralRe: c# app design Pin
MSBassSinger30-Jul-19 7:33
professionalMSBassSinger30-Jul-19 7:33 
AnswerRe: c# app design Pin
BillWoodruff25-Jul-19 15:10
professionalBillWoodruff25-Jul-19 15:10 
GeneralRe: c# app design Pin
Richard Andrew x6427-Jul-19 3:21
professionalRichard Andrew x6427-Jul-19 3:21 
QuestionCrystel Report in Print Duplicate Page Print Pin
Member 1235167123-Jul-19 0:53
Member 1235167123-Jul-19 0:53 
RantRe: Crystel Report in Print Duplicate Page Print Pin
Richard Deeming23-Jul-19 1:00
mveRichard Deeming23-Jul-19 1:00 

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.