Overriding Mdi Child Deactivation

Mar 16, 2011

I know how to handle overriding form closing with FormClosing event and MessageBox prompt by setting e.cancel to true but how can I override deactivation of the mdi child form?

View 3 Replies


ADVERTISEMENT

Interface And Graphics :: MDI Parent / Child - Child To Check To See If It Is The Last Child Object Before Closing

Feb 18, 2011

Im working with MDI parent/child objects. when closing the child objects i need the child to check to see if it is the last child object before closing. i couldn't find anything on google, maybe im searching for the wrong thing.

View 2 Replies

C# - Overriding Events In VB?

Feb 15, 2010

Is there a way to translate this code in VB? Most of it is easy, but I can't figure out a way to override the event handler.

public class MTObservableCollection<T> : ObservableCollection<T>
{
public MTObservableCollection()
{

[code]....

View 2 Replies

Overriding A Method In .net?

Feb 19, 2011

Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing = true And components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

Error: Protected Overrides Sub Dispose(disposing As Boolean)' has multiple definitions with identical signatures.How can I call this without raising an error ?

View 1 Replies

.net - Overriding DataGridViewCell.GetClipboardContent?

Sep 5, 2011

Some of my DataGridViewCells return the wrong value in their GetClipboardContent method. They are cells in a DataGridViewComboBoxColumn cells, so they use the displayed property, not the value property of the cell. I want it to return the value itself.An initial attempt was simply using

Protected Overrides Function GetClipboardContent(ByVal rowIndex As Integer, ByVal firstCell As Boolean, ByVal lastCell As Boolean, ByVal inFirstRow As Boolean, ByVal inLastRow As Boolean, ByVal format As String) As Object Return Value End Function in my DataGridViewComboBoxCell descendant but then I noted that this method is called more than one time per cell value, once for every data format DataGridView supports by standard, which are format="HTML", "Text", "UnicodeText" and "Csv". For csv, the base implementation appends a comma if it's not the last cell, for html it adds the correct tags depending on if it's the first/last row/cell in the table/table row, etc. I consider this format-specific, not cell-value specific.

So how could I replace the value that ends up in the clipboard without re-implementing all those format-specific aspects? That would result in quite some code for functionality that already exists in the base class, wouldn't it?

View 1 Replies

.net - Overriding GetHashCode Variations

Oct 6, 2011

I have a theoretical class Name_Order, that has a string Name and a int Order. I need to indicate that two Name_Order's are different, if the pair NameOrder is different, that is, or name or order are different. Now, overriding Equals no problemo, but I have some "issues" with GetHashCode:

[Code]...

View 2 Replies

Class - Overriding A Sub Procedure?

Sep 17, 2010

I have a main class that has a Sub procedure with no implementation. Any derived class should override and implement this procedure, so I used MustOverride in the base class.

Now, any time this procedure is called, I need to set a specific Boolean variable to True at the beginning of the procedure and set it to False at the end.

Is there a way to avoid writing these two lines of code in procedure implementation of every single derived class? Can I set this value to True in the base class, then run procedure in the derived class and then set the value back in the base class?

View 2 Replies

Overriding Datacontext For View?

Mar 15, 2012

I am setting my viewmodel as datacontext in my xaml but I override it to my view to make few functions work however to achieve the visibility on some grids and I have a property in my VM can I override my datacontext back to my VM? If so how? I have a stackpanel that has datacontext overriden as my grid and within that stackpanel I need to change the datacontext for a button.

View 1 Replies

Overriding DataGridViewTextBoxCell And CellPainting?

Dec 17, 2009

I inherited DataGridViewTextBoxCell because I need to add some custom property to it.

At run-time after creating the DataGridView instance and bind the data I do the following:

For k As Integer = 0 To grid.Columns.Count - 1
grid.Columns(k).AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader
If k > 0 Then grid.Columns(k).CellTemplate = New CustomCell()
Next

[Code]....

the cell type is never of type CustomCell but it remains DataGridViewTextBoxCell.

View 1 Replies

Overriding Equals For An Object With ID

Oct 11, 2011

Is it the best override for Equals (in VB.NET) for an object having an unique ID? [code]I took that example from the MSDN, but not entirely sure if from all points of view (including performance) is the better solution.[code]

View 2 Replies

Overriding The Select In DataViewGrid?

Sep 9, 2010

I have a DataViewGrid that is populated with emp records sorted by a 'header' record listing the managers name. Currently, the user is a ble to select any row, even the manager row. I want to modify the program to prevent users from being able to select the manager record or 'header' record

View 9 Replies

VS 2008 Overriding Subs

Jan 7, 2010

I have an access database for steel members. Each table has a different type of member, and then in those tables, each size of that member type.

I am about to create a tool that draws these sections when they are selected, but as there are 12 different member types, I don't really want to have 12 different Subs for "Draw" that essentially do the same thing.

I considered polymorphism.. (I think I have it correct)

[code...]

View 1 Replies

Alternating Row Color Is Overriding Backcolor?

Feb 23, 2011

I have a DGV with the Alternating row color set to grey.In the CellFormatting event on the DGV I want to go through the rows as if a cell contains a certain value I want to set the BackColor to red.However when I do this, it just gets overridden with the Alternating grey color. The cell in question in a normal colored row appears in red as expected, just not the alternating row.

View 1 Replies

Button And Overriding The Render Event?

Oct 11, 2011

rticularly when creating jQuery buttons with no text and just icons) as a result of this.Secondly I am attempting to create my own custom button output by overriding the Render() event and am having a bit of difficulty trying to understand how to go about changing the output that is provided by this event.If I look at the HtmlTextWriter that is provided as the parameter to the Render() event I can see it contains a protected property TagKey = Input {47}, is it possible to simply modify this property somehow and change it to a Button or do I need to create a new instance of the HtmlTextWriter and populate it all from the start? If so, could anyone provide some guidance as to how this would typically be done and if there are any special considerations I need to make to ensure that my derived button class is functionally equivalent to the original (excluding the html)?

<Assembly: TagPrefix("MyCompany", "MyCustomButton")>
Public Class MyButton
Inherits Button

[code].....

View 2 Replies

Overriding MessageBox Button Language?

Dec 13, 2009

I would like to use the windows messagebox with for exampleyes' and 'no' buttons on it, but I want to be free to choose the lanuage on the buttons.I mean 'Ja' and 'Nein' or 'Oui' and 'Non' instead of the systems default language.

View 2 Replies

Overriding Paint Of Combobox Using WndProc?

May 27, 2009

I've overriden the WndProc of the ComboBox and I am drawing my own combo box, a code snippet is below:

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Select Case m.Msg
Case &HF

[Code]....

Though the old control is still being painted as my drawn combo box is just overlapping the old drawing. Is there a way to stop it drawing the default combo box?

View 1 Replies

Use Of Application Arguments And Overriding Winform Constructor?

May 31, 2012

I was asked to build a winform exe that receives arguments from a web service and decide in which mode the application should start.what is the best way to design and build the application?The application needs to receive 3 arguments.

User name. - stringApplication mode - Boolean (user read write privileges)List on string.
Where do I receive this arguments in the new method ?

View 10 Replies

Duplicate Code And Method Overloading / Overriding

May 18, 2012

This is a general question about Object Orientation and specifically overloading functions in .NET (or any other framework or language). I am looking at an application that has a lot of duplicate code. For example, have a look at the following functions: [code] I would of thought that best pratice would be to put: //code that is specifically relevant to Test1 variable in a separate function as it is common in both functions.

View 2 Replies

Forms :: Overriding WndProc & Message Constants?

Oct 3, 2010

where Windows Message constants can be found in the framework?Example: msg=0x2 (WM_DESTROY) hwnd=0x24038c wparam=0x0 lparam=0x0 result=0x0

I captured that with ...
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)

[code].....

View 9 Replies

Intercepting / Overriding Name Property On Custom Control?

Jun 1, 2012

I have a custom version of a label control (built using a user control). While working in the designer, I want to intercept the setting of the Name property (in the properties panel) and use it to generate the Text property. That is, if I enter "lblFirstName" into the Name property of the properties panel I want to immediately see that the Text property is set to "First Name". Parsing the Name property is not the issue; I can do that.

I have tried to overload/shadow the Name property (since "Overrides" is not allowed) to essentially add this "aspect" to our custom label control but it doesn't seem to hit the Shadowed method at design time. It does hit the Shadowed method at run time if manipulated via code. The point is to avoid double the work as the label text and the label name are essentially the same. The only difference is one is formatted to be human friendly and the other machine friendly.

<System.ComponentModel.Browsable(True),
System.ComponentModel.ParenthesizePropertyName(), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Visible)>
Public Shadows Property Name As String
[Code] .....

This may be a matter of picking the right attributes. Conversely, if it's an easier alternative, we could allow setting the Text property to set the Name property. I doubt this would be easier since it should also reflect the new name in the Designer.vb code, not just in the label's Name property itself.

View 1 Replies

Overriding Default Property Values In .Net, WinForms?

Jan 9, 2010

I create a class "Planet" that can be inherited. One of the purposes of inheriting is to create a template with different default property values. Eg:

Public Sub New
MyBase.New
MyBase.ForeColor = Red

[code]....

Now, to stop the defaults serializing in the InitializeComponent method, there are 2 ways:If I've implemented the properties using the 'DefaultValue' attribute, and made them overridable, the attribute can be overriden with the new value.The problem with this is, there's no way to just make just the attributes overridable, as opposed to the whole property.I could implement every property with protected Reset'PropertyName' and ShouldSerialize'PropertyName' methods. However, this is a bit of a pain in the arse.Is it, generally, an important consideration to ensure that someone who overrides your base class has the ability to change the default values of a property?

View 1 Replies

Overriding Properties Of A Subclass Of An Inherited Class?

Jun 7, 2012

I am trying to override a property of a subclass of an inherited base class. I've tried to simplify this code as much as possible but am not comfortable enough with my own abilities to simplify anything else without loosing the ability to understand an answer.The property propertyName in the otherClass is currently incorrect. I want to be able to override propertyName in baseClass with the propertyName in otherClass. Is this possible to accomplish?

Public Interface interfaceName
Interface iInterfacePropertyName
Enum enumName

[code].....

View 1 Replies

Practical Difference Between Overriding And Shadowing A Function

Apr 4, 2011

Shadows vs. Overrides in VB.Net.What's the difference between shadowing a function in a base class in a subclass and overriding the same function? There is performance issues involved too?I know how to shadow and how to override in VB.net. My question is about when and why should I shadow a function instead override it and vice-versa.

View 2 Replies

VS 2008 Overriding Hashtable's Item(KEY) Property

Mar 24, 2010

I am using a Hashtable which stores unique names and objects associated with those names. Now those objects have a property called "IsDynamic" and some of them have it set to false whie some of them have it set to true. So when I retrieve any object using the key property, it goes to find me that object. How do I override that find method?

[Code]...

View 6 Replies

Work Out If The Mouse Is Over A ToolStripButton When Overriding OnRenderButtonBackground

Apr 27, 2012

I am overriding the OnRenderButtonBackground method in order to use custom colouring, but I want to know if the mouse is currently over the button. I tried to get the parent control (the toolstrip) and the parent form and add all the co-ordinates together but this is not correct:

[Code]...

View 1 Replies

.net - Inheriting A VB Class In C# And Overriding Constructors That Take Optional Parameters?

Jan 12, 2010

Most of our code base is in VB.NET. I'm developing a project in C# that uses a lot of the assemblies from the VB.NET code.There are three relevant classes in VB.NET:

[Code]...

View 3 Replies

.net - Overriding GetHashCode In VB Without Checked/unchecked Keyword Support?

Jan 11, 2011

So I'm trying to figure out how to correctly override GetHashCode() in VB for a large number of custom objects. A bit of searching leads me to this wonderful answer.Except there's one problem: VB lacks both the checked and unchecked keyword in .NET 4.0. As far as I can tell, anyways. So using Jon Skeet's implementation, I tried creating such an override on a rather simple class that has three main members: Name As String, Value As Int32, and [Type] As System.Type. Thus I come up with:

Public Overrides Function GetHashCode() As Int32
Dim hash As Int32 = 17

[code]....

Problem: Int32 is too small for even a simple object such as this. The particular instance I tested has "Name" as a simple 5-character string, and that hash alone was close enough to Int32's upper limit, that when it tried to calc the second field of the hash (Value), it overflowed. Because I can't find a VB equivalent for granular checked/unchecked support, I can't work around this.

I also do not want to remove Integer overflow checks across the entire project. This thing is maybe....40% complete (I made that up, TBH), and I have a lot more code to write, so I need these overflow checks in place for quite some time.

What would be the "safe" version of Jon's GetHashCode version for VB and Int32? Or, does .NET 4.0 have checked/unchecked in it somewhere that I'm not finding very easily on MSDN?

EDIT:Per the linked SO question, one of the unloved answers at the very bottom provided a quasi-solution. I say quasi because it feels like it's....cheating. Beggars can't be choosers, though, right?

Translated from from C# into a more readable VB and aligned to the object described above (Name, Value, Type), we get:

Public Overrides Function GetHashCode() As Int32
Return New With { _
Key .A = _Name, _

[code]....

This triggers the compiler apparently to "cheat" by generating an anonymous type, which it then compiles outside of the project namespace, presumably with integer overflow checks disabled, and allows the math to take place and simply wrap around when it overflows. It also seems to involve box opcodes, which I know to be performance hits. No unboxing, though.

But this raises an interesting question. Countless times, I've seen it stated here and elsewhere that both VB and C# generate the same IL code. This is clearly not the case 100% of the time...Like the use of C#'s unchecked keyword simply causes a different opcode to get emitted. So why do I continue to see the assumption that both produce the exact same IL keep getting repeated? </rhetorical-question>

Anyways, I'd rather find a solution that can be implemented within each object module. Having to create Anonymous Types for every single one of my objects is going to look messy from an ILDASM perspective. I'm not kidding when I say I have a lot of classes implemented in my project.My final implementation, which fits the constraints of GetHashCode, while still being fast and unique enough for VB is below, derived from the "Rotating Hash" example on this page:

'// The only sane way to do hashing in VB.NET because it lacks the
'// checked/unchecked keywords that C# has.
Public Const HASH_PRIME1 As Int32 = 4

[code]....

I also think the "Shift-Add-XOR" hash may also apply, but I haven't tested it.

View 3 Replies

Overriding ColorTable Property In Custom ToolStripProfessionalRenderer Class

Nov 3, 2011

I am trying to use a custom colour scheme for painting my menustrips, toolstrips etc. To do this, I am implementing a custom ToolStripProfessionalRenderer.

Normally i would simply set the renderer of each toolstrip etc. to a new instance of a ToolStripProfessionalRenderer instantaniated with a custom ColorTable i.e.

Dim myRenderer As ToolStripProfessionalRenderer = New ToolStripProfessionalRenderer(New MyColorTable)

View 3 Replies

Overriding System.Diagnostics.Trace.WriteLine To Log To A File?

May 15, 2009

This may be more of an OOP concept question, but here's what I'd like to do.I have an application that outputs debug information using System.Diagnostics.Trace.WriteLine so it can be viewed with DebugView.I'd like to override/extend (not sure of the proper terminology) this method to log the text to a file instead, or maybe in addition to the Trace output. This would allow me to write a new WriteLine method for my app, and I could leave all my other System.Diagnostics.Trace.WriteLine statements unchanged throughout the rest of the application.?

View 2 Replies

Overriding CompareTo When There Are Multiple Ways To Compare Two Objects Of The Same Type?

Jan 12, 2011

What's a sound approach to override the CompareTo() method in a custom class with multiple approaches to comparing the data contained in the class? I'm attempting to implement IComparable(Of T) just so I have a few of the baseline interfaces implemented. Not planning on doing any sorting yet, but this will save me down the road if I need to.

Reading MSDN states mostly that we have to return 0 if the objects are equal, -1 if obj1 is less than obj2, or 1 is obj1 is greater than obj2. But that's rather simplistic.

Consider an IPv4 address (which is what I'm implementing in my class). There's two main numbers to consider -- the IP address itself, and the CIDR. An IPv4 address by itself is assumed to have a CIDR of /32, so in that case, in a CompareTo method, I can just compare the addresses directly to determine if one is greater or less than the other. But when the CIDR's are different, then things get tricky.

Assume obj1 is 10.0.0.0/8 and obj2 is 192.168.75.0/24. I could compare these two addresses a number of ways. I could just ignore the CIDR, and still regard as obj2 as being greater than obj1. I could compare them based on their CIDR, which would be comparing the size of the network (and a /8 will trump a /24 quite easily). I could compare them on both their numerical address AND their CIDR, on the off chance obj2 was actually an address inside the network defined by obj1.

What's the kind of approach used to handle situations like this? Can I define two CompareTo methods, overloaded, such that one would evaluate one address relative to another address, and the second would evaluate the size of the overall network? How would the .NET framework be told which one to use depending on how one might want to sort an array? Or do some other function that relies on CompareTo()?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved