Library question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • > Adrian

    Library question

    I am getting these errors:

    DrawListViewIte mEventArgs' could not be found
    DrawListViewSub ItemEventArgs' could not be found
    DrawListViewCol umnHeaderEventA rgs' could not be found

    I am already referencing both:
    System.Drawing
    System.Drawing. Design

    Which else should I reference to get rid of these errors?

    Adrian.


  • Jani Järvinen [MVP]

    #2
    Re: Library question

    Hello Adrian,

    all the three classes are defined in System.Windows. Forms namespace, so add
    "using System.Windows. Forms;" to your C# code.

    That should do it!

    --
    Regards,

    Mr. Jani Järvinen
    C# MVP
    Helsinki, Finland
    janij@removethi s.dystopia.fi



    Comment

    • jpuopolo

      #3
      Re: Library question

      Adrian:

      Maybe a silly question, but are you including a "using" directive?

      jpuopolo

      "Adrian <" <not@home.anywh erewrote in message
      news:45cc8391$0 $717$5fc3050@dr eader2.news.tis cali.nl...
      >I am getting these errors:
      >
      DrawListViewIte mEventArgs' could not be found
      DrawListViewSub ItemEventArgs' could not be found
      DrawListViewCol umnHeaderEventA rgs' could not be found
      >
      I am already referencing both:
      System.Drawing
      System.Drawing. Design
      >
      Which else should I reference to get rid of these errors?
      >
      Adrian.
      >
      >

      Comment

      • > Adrian

        #4
        Re: Library question

        Not a silly question at all,
        however "using" is there.
        Adrian

        --

        P. de Ridder, drs econ., bsc psych.
        Pearltree Software Development


        "jpuopolo" <jpuopolo@hotma il.comwrote in message
        news:%23pA5ijFT HHA.4252@TK2MSF TNGP05.phx.gbl. ..
        Adrian:
        >
        Maybe a silly question, but are you including a "using" directive?
        >
        jpuopolo
        >
        "Adrian <" <not@home.anywh erewrote in message
        news:45cc8391$0 $717$5fc3050@dr eader2.news.tis cali.nl...
        I am getting these errors:

        DrawListViewIte mEventArgs' could not be found
        DrawListViewSub ItemEventArgs' could not be found
        DrawListViewCol umnHeaderEventA rgs' could not be found

        I am already referencing both:
        System.Drawing
        System.Drawing. Design

        Which else should I reference to get rid of these errors?

        Adrian.
        >
        >

        Comment

        • > Adrian

          #5
          Re: Library question

          If have that reference in.
          So that isn't the cause.
          Adrian.

          "Jani Järvinen [MVP]" <janij@removeth is.dystopia.fiw rote in message
          news:OGvAviFTHH A.2228@TK2MSFTN GP03.phx.gbl...
          Hello Adrian,
          >
          all the three classes are defined in System.Windows. Forms namespace, so
          add
          "using System.Windows. Forms;" to your C# code.
          >
          That should do it!
          >
          --
          Regards,
          >
          Mr. Jani Järvinen
          C# MVP
          Helsinki, Finland
          janij@removethi s.dystopia.fi

          >
          >

          Comment

          • Jani Järvinen [MVP]

            #6
            Re: Library question

            Hello,

            can you post your code that shows the error and the complete error message?

            There must be something else going on in your code if you have the
            references/using statements already in place.

            --
            Regards,

            Mr. Jani Järvinen
            C# MVP
            Helsinki, Finland
            janij@removethi s.dystopia.fi



            Comment

            • Willy Denoyette [MVP]

              #7
              Re: Library question

              "Adrian <" <not@home.anywh erewrote in message
              news:45cc8391$0 $717$5fc3050@dr eader2.news.tis cali.nl...
              >I am getting these errors:
              >
              DrawListViewIte mEventArgs' could not be found
              DrawListViewSub ItemEventArgs' could not be found
              DrawListViewCol umnHeaderEventA rgs' could not be found
              >
              I am already referencing both:
              System.Drawing
              System.Drawing. Design
              >
              Which else should I reference to get rid of these errors?
              >
              Adrian.
              >
              >
              Are you sure you are using Framework v2.0?

              Willy.



              Comment

              • > Adrian

                #8
                Re: Library question

                The code was taken from MSDN

                using System;
                using System.Drawing;
                using System.Drawing. Drawing2D;
                using System.Globaliz ation;
                using System.Windows. Forms;

                namespace WindowsApplicat ion1
                {
                public class Form1: Form
                {
                private ListView listView1 = new ListView();
                private ContextMenu contextMenu1 = new ContextMenu();

                public Form1()
                {
                // Initialize the ListView control.
                listView1.BackC olor = Color.Black;
                listView1.ForeC olor = Color.White;
                listView1.Dock = DockStyle.Fill;
                listView1.View = View.Details;
                listView1.FullR owSelect = true;

                // Add columns to the ListView control.
                listView1.Colum ns.Add("Name", 72, HorizontalAlign ment.Center);
                listView1.Colum ns.Add("First", 72, HorizontalAlign ment.Center);
                listView1.Colum ns.Add("Second" , 72, HorizontalAlign ment.Center);
                listView1.Colum ns.Add("Third", 72, HorizontalAlign ment.Center);

                // Create items and add them to the ListView control.
                ListViewItem listViewItem1 = new ListViewItem(ne w string[] { "One", "20",
                "30", "-40" }, -1);
                ListViewItem listViewItem2 = new ListViewItem(ne w string[] { "Two",
                "-250", "145", "37" }, -1);
                ListViewItem listViewItem3 = new ListViewItem(ne w string[] { "Three",
                "200", "800", "-1,001" }, -1);
                ListViewItem listViewItem4 = new ListViewItem(ne w string[] { "Four", "not
                available", "-2", "100" }, -1);
                listView1.Items .AddRange(new ListViewItem[] { listViewItem1,
                listViewItem2, listViewItem3, listViewItem4 });

                // Initialize the shortcut menu and
                // assign it to the ListView control.
                contextMenu1.Me nuItems.Add("Li st", new EventHandler(me nuItemList_Clic k));
                contextMenu1.Me nuItems.Add("De tails", new
                EventHandler(me nuItemDetails_C lick));
                listView1.Conte xtMenu = contextMenu1;

                // Configure the ListView control for owner-draw and add
                // handlers for the owner-draw events.
                listView1.Owner Draw = true;
                listView1.DrawI tem += new
                DrawListViewIte mEventHandler(l istView1_DrawIt em);
                listView1.DrawS ubItem += new
                DrawListViewSub ItemEventHandle r(listView1_Dra wSubItem);
                listView1.DrawC olumnHeader += new
                DrawListViewCol umnHeaderEventH andler(listView 1_DrawColumnHea der);

                // Add a handler for the MouseMove event to compensate for an
                // extra DrawItem event that occurs the first time the mouse
                // moves over each row.
                listView1.Mouse Move += new MouseEventHandl er(listView1_Mo useMove);

                // Add a handler for the MouseUp event so an item can be
                // selected by clicking anywhere along its width.
                listView1.Mouse Up += new MouseEventHandl er(listView1_Mo useUp);

                // Initialize the form and add the ListView control to it.
                this.ClientSize = new Size(292, 79);
                this.FormBorder Style = FormBorderStyle .FixedSingle;
                this.MaximizeBo x = false;
                this.Text = "ListView OwnerDraw Example";
                this.Controls.A dd(listView1);
                }

                // Clean up any resources being used.
                protected override void Dispose(bool disposing)
                {
                if (disposing)
                {
                contextMenu1.Di spose();
                }
                base.Dispose(di sposing);
                }

                [STAThread]
                static void Main()
                {
                Application.Ena bleVisualStyles ();
                Application.Run (new ListViewOwnerDr aw());
                }

                // Sets the ListView control to the List view.
                private void menuItemList_Cl ick(object sender, EventArgs e)
                {
                listView1.View = View.List;
                listView1.Inval idate();
                }

                // Sets the ListView control to the Details view.
                private void menuItemDetails _Click(object sender, EventArgs e)
                {
                listView1.View = View.Details;

                // Reset the tag on each item to re-enable the workaround in
                // the MouseMove event handler.
                foreach (ListViewItem item in listView1.Items )
                {
                item.Tag = null;
                }
                }

                // Selects and focuses an item when it is clicked anywhere along
                // its width. The click must normally be on the parent item text.
                private void listView1_Mouse Up(object sender, MouseEventArgs e)
                {
                ListViewItem clickedItem = listView1.GetIt emAt(5, e.Y);
                if (clickedItem != null)
                {
                clickedItem.Sel ected = true;
                clickedItem.Foc used = true;
                }
                }

                // Draws the backgrounds for entire ListView items.
                private void listView1_DrawI tem(object sender, DrawListViewIte mEventArgs
                e)
                {
                if ((e.State & ListViewItemSta tes.Selected) != 0)
                {
                // Draw the background and focus rectangle for a selected item.
                e.Graphics.Fill Rectangle(Brush es.Maroon, e.Bounds);
                e.DrawFocusRect angle();
                }
                else
                {
                // Draw the background for an unselected item.
                using (LinearGradient Brush brush =
                new LinearGradientB rush(e.Bounds, Color.Orange,
                Color.Maroon, LinearGradientM ode.Horizontal) )
                {
                e.Graphics.Fill Rectangle(brush , e.Bounds);
                }
                }

                // Draw the item text for views other than the Details view.
                if (listView1.View != View.Details)
                {
                e.DrawText();
                }
                }

                // Draws subitem text and applies content-based formatting.
                private void listView1_DrawS ubItem(object sender,
                DrawListViewSub ItemEventArgs e)
                {
                TextFormatFlags flags = TextFormatFlags .Left;

                using (StringFormat sf = new StringFormat())
                {
                // Store the column text alignment, letting it default
                // to Left if it has not been set to Center or Right.
                switch (e.Header.TextA lign)
                {
                case HorizontalAlign ment.Center:
                sf.Alignment = StringAlignment .Center;
                flags = TextFormatFlags .HorizontalCent er;
                break;
                case HorizontalAlign ment.Right:
                sf.Alignment = StringAlignment .Far;
                flags = TextFormatFlags .Right;
                break;
                }

                // Draw the text and background for a subitem with a
                // negative value.
                double subItemValue;
                if (e.ColumnIndex 0 && Double.TryParse (
                e.SubItem.Text, NumberStyles.Cu rrency,
                NumberFormatInf o.CurrentInfo, out subItemValue) &&
                subItemValue < 0)
                {
                // Unless the item is selected, draw the standard
                // background to make it stand out from the gradient.
                if ((e.ItemState & ListViewItemSta tes.Selected) == 0)
                {
                e.DrawBackgroun d();
                }

                // Draw the subitem text in red to highlight it.
                e.Graphics.Draw String(e.SubIte m.Text,
                listView1.Font, Brushes.Red, e.Bounds, sf);

                return;
                }

                // Draw normal text for a subitem with a nonnegative
                // or nonnumerical value.
                e.DrawText(flag s);
                }
                }

                // Draws column headers.
                private void listView1_DrawC olumnHeader(obj ect sender,
                DrawListViewCol umnHeaderEventA rgs e)
                {
                using (StringFormat sf = new StringFormat())
                {
                // Store the column text alignment, letting it default
                // to Left if it has not been set to Center or Right.
                switch (e.Header.TextA lign)
                {
                case HorizontalAlign ment.Center:
                sf.Alignment = StringAlignment .Center;
                break;
                case HorizontalAlign ment.Right:
                sf.Alignment = StringAlignment .Far;
                break;
                }

                // Draw the standard header background.
                e.DrawBackgroun d();

                // Draw the header text.
                using (Font headerFont =
                new Font("Helvetica ", 10, FontStyle.Bold) )
                {
                e.Graphics.Draw String(e.Header .Text, headerFont,
                Brushes.Black, e.Bounds, sf);
                }
                }
                return;
                }

                // Forces each row to repaint itself the first time the mouse moves over
                // it, compensating for an extra DrawItem event sent by the wrapped
                // Win32 control.
                private void listView1_Mouse Move(object sender, MouseEventArgs e)
                {
                ListViewItem item = listView1.GetIt emAt(e.X, e.Y);
                if (item != null && item.Tag == null)
                {
                listView1.Inval idate(item.Boun ds);
                item.Tag = "tagged";
                }
                }
                }
                }
                "Jani Järvinen [MVP]" <janij@removeth is.dystopia.fiw rote in message
                news:euOz43FTHH A.1212@TK2MSFTN GP03.phx.gbl...
                Hello,
                >
                can you post your code that shows the error and the complete error
                message?
                >
                There must be something else going on in your code if you have the
                references/using statements already in place.
                >
                --
                Regards,
                >
                Mr. Jani Järvinen
                C# MVP
                Helsinki, Finland
                janij@removethi s.dystopia.fi

                >
                >

                Comment

                • > Adrian

                  #9
                  Re: Library question

                  Yes I have it on board
                  Adrian

                  "Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
                  news:OdLjKUHTHH A.1036@TK2MSFTN GP03.phx.gbl...
                  "Adrian <" <not@home.anywh erewrote in message
                  news:45cc8391$0 $717$5fc3050@dr eader2.news.tis cali.nl...
                  I am getting these errors:

                  DrawListViewIte mEventArgs' could not be found
                  DrawListViewSub ItemEventArgs' could not be found
                  DrawListViewCol umnHeaderEventA rgs' could not be found

                  I am already referencing both:
                  System.Drawing
                  System.Drawing. Design

                  Which else should I reference to get rid of these errors?

                  Adrian.
                  >
                  Are you sure you are using Framework v2.0?
                  >
                  Willy.
                  >
                  >
                  >

                  Comment

                  • > Adrian

                    #10
                    Re: Library question

                    I have got it to run. It would not run on VS2003, but it will run on V2005.
                    I did make some changes though. However the header back color is read only,
                    so I am stuck, because specifically that I wanted to change.

                    Adrian


                    "Adrian <" <not@home.anywh erewrote in message
                    news:45ccd62e$0 $727$5fc3050@dr eader2.news.tis cali.nl...
                    Yes I have it on board
                    Adrian
                    >
                    "Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
                    news:OdLjKUHTHH A.1036@TK2MSFTN GP03.phx.gbl...
                    "Adrian <" <not@home.anywh erewrote in message
                    news:45cc8391$0 $717$5fc3050@dr eader2.news.tis cali.nl...
                    >I am getting these errors:
                    >
                    DrawListViewIte mEventArgs' could not be found
                    DrawListViewSub ItemEventArgs' could not be found
                    DrawListViewCol umnHeaderEventA rgs' could not be found
                    >
                    I am already referencing both:
                    System.Drawing
                    System.Drawing. Design
                    >
                    Which else should I reference to get rid of these errors?
                    >
                    Adrian.
                    >
                    >
                    Are you sure you are using Framework v2.0?

                    Willy.

                    >
                    >

                    Comment

                    • Willy Denoyette [MVP]

                      #11
                      Re: Library question

                      "Adrian <" <not@home.anywh erewrote in message
                      news:45cdbfe4$0 $711$5fc3050@dr eader2.news.tis cali.nl...
                      >I have got it to run. It would not run on VS2003, but it will run on V2005.
                      I did make some changes though. However the header back color is read only,
                      so I am stuck, because specifically that I wanted to change.
                      >
                      >
                      So you were not running V2 of the framework after all, VS2003 targets V1.x!

                      Willy.

                      Comment

                      Working...