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

vb event in c#?

i'm trying to convert some code from VB to C#, i know i can use both in .net,
but we know C# better and want to be able to change some things around for
our own needs. i have all of it converted except for the "public event..."
of the following code. is there anyone that can help me convert this to C#
please?

thank you in advance,

Public Class ColumnInformation
Private m_Field As String
Private m_Width As Single
Private m_HeaderText As String
Private m_HeaderFont As Font
Private m_DetailFont As Font
Private m_Alignment As StringAlignment

Public Event FormatColumn(ByVal sender As Object, ByRef e As
FormatColumnEventArgs)

Public Function GetString(ByVal Value As Object)
Dim e As New FormatColumnEventArgs()
e.OriginalValue = Value
If Not IsDBNull(Value) Then
e.StringValue = CStr(Value)
Else
e.StringValue = "<NULL>"
End If

RaiseEvent FormatColumn(CObj(Me), e)
Return e.StringValue
End Function

Public Sub New(ByVal Field As String, _
ByVal Width As Single, _
ByVal Alignment As StringAlignment)
m_Field = Field
m_Width = Width
m_Alignment = Alignment
End Sub

Public Property Field() As String
Get
Return m_Field
End Get
Set(ByVal Value As String)
m_Field = Value
End Set
End Property

Public Property Width() As Single
Get
Return m_Width
End Get
Set(ByVal Value As Single)
m_Width = Value
End Set
End Property

Public Property Alignment() As StringAlignment
Get
Return m_Alignment
End Get
Set(ByVal Value As StringAlignment)
m_Alignment = Value
End Set
End Property

Public Property HeaderFont() As Font
Get
Return m_HeaderFont
End Get
Set(ByVal Value As Font)
m_HeaderFont = Value
End Set
End Property

Public Property HeaderText() As String
Get
Return m_HeaderText
End Get
Set(ByVal Value As String)
m_HeaderText = Value
End Set
End Property

Public Property DetailFont() As Font
Get
Return m_DetailFont
End Get
Set(ByVal Value As Font)
m_DetailFont = Value
End Set
End Property
End Class

Nov 16 '05 #1
3 1477
Hi Oscar,
Public Event FormatColumn(ByVal sender As Object, ByRef e As
FormatColumnEventArgs)


in c#

public delegate void FormatColumnEventHandler(object sender, ref
FormatColumnsEventArgs e)

public event FormatColumnEventHandler FormatColumn
Roland
Nov 16 '05 #2
Oscar,

I think that this is a nice page about your problem. Seems for me that there
is nothing to add to that.

http://msdn.microsoft.com/library/de...ctionality.asp

I hope this helps?

Cor
Nov 16 '05 #3

thanx for the help, that's what i needed, but now i have a new questions...

in order to call the event handler from another function the VB code looks
like :

Dim orderID As New ColumnInformation("OrderID", 1,
StringAlignment.Near)
Dim orderDate As New ColumnInformation("OrderDate", 1,
StringAlignment.Center)
AddHandler orderDate.FormatColumn, AddressOf FormatDateColumn
i thought it should look like the following, but i can not seem to put the
right information into the EventHandler.
ColumnInformation orderID = new ColumnInformation("OrderID", 1,
StringAlignment.Near);
ColumnInformation orderDate = new ColumnInformation("OrderDate", 1,
StringAlignment.Center);
orderDate.FormatColumn += new EventHandler(FormatDateColumn);

i also tried using :
orderDate.FormatColumn += new FormatColumnEventHandler(FormateDateColumn);

but that told me it doesn't exist

thanks again for the help
Nov 16 '05 #4

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

Similar topics

0
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
8
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that...
9
by: VK | last post by:
My original idea of two trains, however pictural it was, appeared to be wrong. The truth seems to be even more chaotic. IE implements its standard down-up model: any mouse event goes from the...
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
19
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void...
5
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the...
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:
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.