473,320 Members | 1,952 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,320 software developers and data experts.

Handles syntax in C# - must be easy

I can't find this answer anywhere! I am making a class that inherits
from StatusBar control and I want to convert this function to C#...

Private Sub Reposition(ByVal sender As Object, _
ByVal sbdevent As System.Windows.Forms.StatusBarDrawItemEventArgs) _
Handles MyBase.DrawItem
....
End Sub

i can't override the DrawItem method, nor can I make an event handler with

this.DrawItem += new EventHandler ...

how can I do this?

it is from this project:

http://www.codeproject.com/vb/net/ProgressStatus.asp

thanks!

Ed
Nov 16 '05 #1
2 1213
nevermind, i figured it out... the this.DrawItem += had to be in a method.

in the constructor:

this.DrawItem += new
StatusBarDrawItemEventHandler(this.ProgressStatus_ DrawItem);
private void ProgressStatus_DrawItem(object sender,
StatusBarDrawItemEventArgs sbdevent ) {
...
}

thanks anyway!

Ed

Ed West wrote:
I can't find this answer anywhere! I am making a class that inherits
from StatusBar control and I want to convert this function to C#...

Private Sub Reposition(ByVal sender As Object, _
ByVal sbdevent As System.Windows.Forms.StatusBarDrawItemEventArgs) _
Handles MyBase.DrawItem
....
End Sub

i can't override the DrawItem method, nor can I make an event handler with

this.DrawItem += new EventHandler ...

how can I do this?

it is from this project:

http://www.codeproject.com/vb/net/ProgressStatus.asp

thanks!

Ed

Nov 16 '05 #2
If you are handling the base class's event in the derived class, you
might want to consider overriding the OnDrawItem() method instead. Even
if you want to do things _in addition to_ what your base class does
when the DrawItem event happens, you can still do it in an overridden
method. If you want your derived class to do things _instead of_ what
your base class does when the DrawItem event happens, overriding
OnDrawItem() is the only way to achieve this.

I suggest this because it's a more usual idiom in the derived class:
override the appropriate On...() methods, rather than subscribing to
the parent's events.

Nov 16 '05 #3

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
24
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
75
by: David MacQuigg | last post by:
Seems like we need a simple way to extend Python syntax that doesn't break existing syntax or clash with any other syntax in Python, is easy to type, easy to read, and is clearly distinct from the...
23
by: C. Barnes | last post by:
I vote for def f(): (body of function) This is backwards compatible (Python <= 2.3 raise SyntaxError), and looks much nicer than @. The only problem is that you can't one-line a...
177
by: C# Learner | last post by:
Why is C syntax so uneasy on the eye? In its day, was it _really_ designed by snobby programmers to scare away potential "n00bs"? If so, and after 50+ years of programming research, why are...
3
by: Sean | last post by:
HI There, I am trying to submit a form when a selection is made from a dropdown list, I keep getting the error "Handles clause requires With Events Variable". Could someone help me with the...
3
by: astromog | last post by:
I have some significantly extended syntax for Python that I need to create a reference implementation for. My new syntax includes new keywords, statements and objects that are sort of like classes...
3
by: Rob R. Ainscough | last post by:
What sick saddistic person came up with the JavaScript language syntax? And was it the same person (or group of people) that came up with the HTML syntax?? OMG, has no one noticed this hopeless...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.