473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Where to call MyBase.OnDrawItem(e)

In
Protected Overrides Sub OnDrawItem

should I call

MyBase.OnDrawItem(e)

at the top or bottom of the sub?

What might happen if I don't call it?

Thanks

I assume any answer to the above applies to

Protected Overrides Sub OnMeasureItem

right?
Jun 10 '07 #1
6 2700
The CheckedListBox overrides this method from its base class (ListBox) and
does not call MyBase.OnDrawItem. I would expect that you will be okay if you
do the same.

Tony

"active" wrote:
In
Protected Overrides Sub OnDrawItem

should I call

MyBase.OnDrawItem(e)

at the top or bottom of the sub?

What might happen if I don't call it?

Thanks

I assume any answer to the above applies to

Protected Overrides Sub OnMeasureItem

right?
Jun 11 '07 #2
Tony,
I'm not being argumentive, really just curious, how can you know what you
said?
I read the doc and it sound like it raises the DrawItem event instead of
calling OnDrawItem which would cause (I think) the base class to raise the
event.
The doc sounds like that but it doesn't really say that so I think you get
your info some other way.

Second question:
Is there some rule as to when to call the base "On" sub - at the your or
bottom of your overriding sub?
thanks a lot


"tlkerns" <tl*****@discussions.microsoft.comwrote in message
news:95**********************************@microsof t.com...
The CheckedListBox overrides this method from its base class (ListBox) and
does not call MyBase.OnDrawItem. I would expect that you will be okay if
you
do the same.

Tony

"active" wrote:
>In
Protected Overrides Sub OnDrawItem

should I call

MyBase.OnDrawItem(e)

at the top or bottom of the sub?

What might happen if I don't call it?

Thanks

I assume any answer to the above applies to

Protected Overrides Sub OnMeasureItem

right?

Jun 11 '07 #3
1. Using Lutz Roeder's .NET Reflector, you can look at the source code of
the Base Class Libraries of the .NET Framework.
http://www.aisto.com/roeder/dotnet/
2. I don't know of any, but with the tool above, you can look at the base
method and see what would happen if you didn't.

Tony
"active" wrote:
Tony,
I'm not being argumentive, really just curious, how can you know what you
said?
I read the doc and it sound like it raises the DrawItem event instead of
calling OnDrawItem which would cause (I think) the base class to raise the
event.
The doc sounds like that but it doesn't really say that so I think you get
your info some other way.

Second question:
Is there some rule as to when to call the base "On" sub - at the your or
bottom of your overriding sub?
thanks a lot


"tlkerns" <tl*****@discussions.microsoft.comwrote in message
news:95**********************************@microsof t.com...
The CheckedListBox overrides this method from its base class (ListBox) and
does not call MyBase.OnDrawItem. I would expect that you will be okay if
you
do the same.

Tony

"active" wrote:
In
Protected Overrides Sub OnDrawItem

should I call

MyBase.OnDrawItem(e)

at the top or bottom of the sub?

What might happen if I don't call it?

Thanks

I assume any answer to the above applies to

Protected Overrides Sub OnMeasureItem

right?


Jun 11 '07 #4
Thanks, I'll download it

"tlkerns" <tl*****@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...
1. Using Lutz Roeder's .NET Reflector, you can look at the source code of
the Base Class Libraries of the .NET Framework.
http://www.aisto.com/roeder/dotnet/
2. I don't know of any, but with the tool above, you can look at the base
method and see what would happen if you didn't.

Tony
"active" wrote:
>Tony,
I'm not being argumentive, really just curious, how can you know what you
said?
I read the doc and it sound like it raises the DrawItem event instead of
calling OnDrawItem which would cause (I think) the base class to raise
the
event.
The doc sounds like that but it doesn't really say that so I think you
get
your info some other way.

Second question:
Is there some rule as to when to call the base "On" sub - at the your or
bottom of your overriding sub?
thanks a lot


"tlkerns" <tl*****@discussions.microsoft.comwrote in message
news:95**********************************@microso ft.com...
The CheckedListBox overrides this method from its base class (ListBox)
and
does not call MyBase.OnDrawItem. I would expect that you will be okay
if
you
do the same.

Tony

"active" wrote:

In
Protected Overrides Sub OnDrawItem

should I call

MyBase.OnDrawItem(e)

at the top or bottom of the sub?

What might happen if I don't call it?

Thanks

I assume any answer to the above applies to

Protected Overrides Sub OnMeasureItem

right?



Jun 11 '07 #5
active,

It depends.

First, which control are you referring to? Checking in Reflector
(http://www.aisto.com/roeder/dotnet/), this could include the ListBox,
CheckedListBox, ComboBox, ListView, MenuItem, StatusBar or TabControl, all
in the System.Windows.Forms namespace.

I'll pick the ListBox. By overriding the OnDrawItem method (event), you are
saying that you want to handle the functionality contained in the base
method to draw the ListItem yourself. If you want to add to the base
functionality, you can call MyBase.OnDrawItem first. The item is then drawn
per the base code, and then you can 'add' on top of it. If you call it at
the end, you will have overwritten the drawing you may have already
performed. If you don't call it at all, then it is completely up to you to
provide the mechanics to 'draw' the item.

I would recommend building a simple WinForms app, just a throwaway in 2005,
and testing it both ways to get a clearer picture of what I described above.

The key to calling the base method in an override is to understand what
functionality occurs in the base method, whether you want that
functionality, and therefore whether that functionality should occur before
or after the user logic in your derived method.

Hope this helps,
Steve

" active" <ac**********@a-znet.comwrote in message
news:ef**************@TK2MSFTNGP04.phx.gbl...
In
Protected Overrides Sub OnDrawItem

should I call

MyBase.OnDrawItem(e)

at the top or bottom of the sub?

What might happen if I don't call it?

Thanks

I assume any answer to the above applies to

Protected Overrides Sub OnMeasureItem

right?


Jun 13 '07 #6
Make it very clear - thanks
"PlatinumBay" <st*******@community.nospamwrote in message
news:eo**************@TK2MSFTNGP06.phx.gbl...
active,

It depends.

First, which control are you referring to? Checking in Reflector
(http://www.aisto.com/roeder/dotnet/), this could include the ListBox,
CheckedListBox, ComboBox, ListView, MenuItem, StatusBar or TabControl, all
in the System.Windows.Forms namespace.

I'll pick the ListBox. By overriding the OnDrawItem method (event), you
are saying that you want to handle the functionality contained in the base
method to draw the ListItem yourself. If you want to add to the base
functionality, you can call MyBase.OnDrawItem first. The item is then
drawn per the base code, and then you can 'add' on top of it. If you call
it at the end, you will have overwritten the drawing you may have already
performed. If you don't call it at all, then it is completely up to you
to provide the mechanics to 'draw' the item.

I would recommend building a simple WinForms app, just a throwaway in
2005, and testing it both ways to get a clearer picture of what I
described above.

The key to calling the base method in an override is to understand what
functionality occurs in the base method, whether you want that
functionality, and therefore whether that functionality should occur
before or after the user logic in your derived method.

Hope this helps,
Steve

" active" <ac**********@a-znet.comwrote in message
news:ef**************@TK2MSFTNGP04.phx.gbl...
>In
Protected Overrides Sub OnDrawItem

should I call

MyBase.OnDrawItem(e)

at the top or bottom of the sub?

What might happen if I don't call it?

Thanks

I assume any answer to the above applies to

Protected Overrides Sub OnMeasureItem

right?



Jun 13 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: ByteSize | last post by:
Dear All, Please, this is not meant to be offensive - but it is a challenge !!! I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete,...
5
by: Stan Sainte-Rose | last post by:
Hi, How can I call an event from an action. Example, I want to call the datagrid.Double.click event when a button is pressed. Stan.
7
by: Microsoft | last post by:
I'm not sure where to physically place my subroutines in vb.net I get namespace and not declared errors... Imports System Imports System.Management Public Class Form1
2
by: Wayne Wengert | last post by:
I have a VB App (VSNET 2003) in which, during form load, I create a dataset (ds1) and then populate a datagrid by binding to the dataset. That works fine. The form has a button which, when clicked,...
10
by: mttc | last post by:
I read articles that suggest preventing delete by throwing Exception from RowDeleting Event. I not understand where I can catch this Error?
9
by: Andy | last post by:
Hi, is it in C++ possible to call a constructor from another constructor? In Java you can do the following: public class MyClass { public MyClass() { this(10);
2
by: Jack | last post by:
Hello, I have a 3-level class hirarchy: 1=Grandparent 2=Parent 3=Child The Grandparent has a method called OnPaint which I want to override from the Child class. I can do this, but how...
7
by: Siegfried Heintze | last post by:
How does the partial class feature work with Visual Studio (VS) and VB.NET? Does VB have the keyword partial like C# does? I don't see it in my wizard generated WinForm application. In C#, I see...
2
by: Reggie | last post by:
Hi and TIA! I have a class file located in my root directory with all me web pages. I call/use the class and it works fine. I have no imports statements aspx or codebehind. My question is why? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.