|
An explorer like composite developed with VB.Net
|
Total Hit (3059) |
This composite implements an explorer "light" developed in VB.Net. The explorer provides for automatic resizing. The example provides for an explorer contained in a resizable panel on a resizeable form
|
Rating
|
|
|
A cheap way to display files and hex data
|
Total Hit (4489) |
The .NET framework includes a ByteViewer control, that you can use on your own forms to display data stored in a Byte array or in a file. The ByteViewer control can't be added to the control Toolbox, though, so you must instantiate it through code only.
«Code LangId=2»
' IMPORTANT: this code re
....Read More |
Rating
|
|
|
Adding an image as an embedded resource, and loading it from code
|
Total Hit (3749) |
To add an image as an embedded resource in a Windows Forms application, add the image file to the project with Project | Add Existing Item. Then select the file in the Solution Explorer, go to the Properties Window, and set its Build Action property to Embedded Resource. At this point the file will
....Read More |
Rating
|
|
|
Adding events dynamically in a Windows Form
|
Total Hit (2949) |
The new AddHandler statement makes it possible to attach event dynamically, that is without having to bind them via static code based on the Handles keyword. This keyword is also useful to have all the controls on a form share the same event procedure.
For example, say that you want to change th
....Read More |
Rating
|
|
|
Bind a DataGrid to a DataSet at design-time
|
Total Hit (3361) |
Binding a DataGrid - or any other data-aware control - to a DataSet or a DataTable at runtime isn't difficult: you just have to assign the DataTable to the DataGrid's DataSource property, as in:
«Code LangId=2»
' DS is the DataSet variable
DataGrid1.DataSource = ds.Tables("Titles")
«/Code»
....Read More |
Rating
|
|
|
Adding an image as an embedded resource, and loading it from code
|
Total Hit (2672) |
To add an image as an embedded resource in a Windows Forms application, add the image file to the project with Project | Add Existing Item. Then select the file in the Solution Explorer, go to the Properties Window, and set its Build Action property to Embedded Resource. At this point the file will
....Read More |
Rating
|
|
|
Copying data into the Clipboard
|
Total Hit (4673) |
Copying a piece of information into the clipboard is as easy as calling the Clipboard.SetDataObject: you can pass this method a string, an image, and so on. If you pass it a string that contains text in Rich Text Format (RTF), the Clipboard object detects this format automatically. For example, the
....Read More |
Rating
|
|
|
Creating multiline tooltips
|
Total Hit (3515) |
In VB6 there was no easy way to create multiline tooltips for form controls, you necessarily had to resort to API tricks. And it was probably just not worth the effort. The good news is that doing this is straightforward in VB.NET! First add a Tooltip Provider control on the form to add the Tooltip
....Read More |
Rating
|
|
|
Multi-column menus
|
Total Hit (3657) |
The new Break and BarBreak properties of the MenuItem object let you create menus with multiple columns. All you have to do is set either property to True for the MenuItem object that must become the first item of a new menu column. The only difference between these two properties is that BarBreak d
....Read More |
Rating
|
|
|
Pasting data from the Clipboard
|
Total Hit (6430) |
Pasting data from the clipboard requires more code because you must ascertain whether the clipboard contains data in one of the formats you're willing to process. First, use the Clipboard.GetDataObject to retrieve an IDataObject object. Next, use the GetDataPresent method of this IDataObject object
....Read More |
Rating
|
|
|
Showing and enumerating MDI child forms
|
Total Hit (3272) |
An MDI child form is a regular form whose MdiParent property points to its MDI container form, so the code that creates and displays a child window is very simple:
«Code LangId=2»
Sub ShowMdiChildWindow()
' Display the MenuForm form as a child of this form.
Dim frm As New MenuForm()
....Read More |
Rating
|
|
|
Unload setup projects before running the Inheritance Picker
|
Total Hit (2906) |
If your solution contains a setup project and this setup project has been built at least once, you get an Assembly Load error when you run the Inheritance Picker in order to inherit from an existing form in your main project.
This problem occurs because the setup project generates several execut
....Read More |
Rating
|
|
|
Use VB6 ActiveX controls with VB.NET
|
Total Hit (4105) |
It is possible to use VB6 ActiveX controls - such as ADO Data Control, Chart Control, Comm Control, and the Windowless controls - with the designer of Visual Studio .NET, but you may encounter problems when doing so because VS.NET doesn't come with the design-time license for these controls, therefo
....Read More |
Rating
|
|
|
Working with owned forms
|
Total Hit (3277) |
If a form owns another form, the owned form will be always displayed in front of its owner form, no matter which is the active form. This makes owned forms ideal for implementing tool and palette windows. Another feature of owned forms: when the user closes or minimizes the owner form, all the owned
....Read More |
Rating
|
|
|
Don’t use the GotFocus and LostFocus events
|
Total Hit (4561) |
Have you ever tried to change the BorderStyle, HideSelection, MultiLine, ScrollBars, WordWrap and TextAlign properties of a TextBox, or the ComboBox’s RightToLeft property from inside the control’s GotFocus or LostFocus events? You’ll get a System.ComponentModel.Win32Exception exception saying "Erro
....Read More |
Rating
|
|
|
Hiding pages of a TabControl
|
Total Hit (2861) |
Sometimes you may need to hide or show some pages of a TabControl according to the information you want to show, basing on the currently logged-in user for example (users with low privileges won't be able to get all the information or to change records). To do this, you may attempt to add or remove
....Read More |
Rating
|
|
|
Map an enumerated value to a set of OptionButton controls
|
Total Hit (2645) |
In VB6 and previous version, displaying an enumerated value in a group of option buttons is quite simple, provided that the option buttons be grouped in a control array. VB.NET doesn't support control arrays, so you can't reuse the same simple coding techniques. However, you can prepare a couple of
....Read More |
Rating
|
|
|
Skipping columns when tabbing on a DataGrid
|
Total Hit (3680) |
It happens quite often that you have a DataGrid with hidden columns (with width = 0), because you need their values but don't want to show them to the user. However, when you tab through the DataGrid's columns, these "hidden" columns are still taken into account in the tab order. This means that whe
....Read More |
Rating
|
|
|
Using multiple fields as value for the DropDownList control's items
|
Total Hit (4208) |
Being an avid Access Programmer I have been frustrated with the limitation of VB DropDownLists to using only 1 field as the value. I found a way to simulate/work around this behavior with concatenation of several database fields at the query level to be my columns(i.e. Select KeyId1 + '~' + KeyId2 +
....Read More |
Rating
|
|
|
Creating owner drawn menu items to simulate a color picker
|
Total Hit (3737) |
«Code LangId=2»' This class does the owner drawing of a MenuItem to draw a color box.
' The class inherits from MenuItem, thus the ColorMenuItem objects
' can be added to a parent MenuItem or a context menu as you
' normally do, and can also be mixed with other MenuItem items
' under the same
....Read More |
Rating
|
|
|
ExplodeForm - Showing a form with an explosion effect
|
Total Hit (4077) |
«Code LangId=2»
' Show a form with an explosion effect.
' the numSteps parameter is the number of steps to increase the form size from
' 0 to the original size
' the stepDuration argument is the number of milliseconds between each step
' Example:
' Private Sub Form1_Activated(...) Handles
....Read More |
Rating
|
|
|
|
ImplodeForm - Hiding a form with an implosion effect
|
Total Hit (2910) |
«Code LangId=2»' Hiding a form with an implosion effect.
' the numSteps parameter is the number of steps to decrease the form size from
' the current size to 0
' the stepDuration argument is the number of milliseconds between each step
' Example:
' Private Sub Form1_Closing(...) Handles My
....Read More |
Rating
|
|
|
MoveListboxItem - Moving an item of a listbox to another index
|
Total Hit (2629) |
«Code LangId=2»
' Moves an item of a listbox to another index
' If FROMINDEX = -1 then it moves the current highlighted item
'
' Example:
' ' move up the selected item
' MoveListboxItem(ListBox1, -1, ListBox1.SelectedIndex - 1)
' ' move down the selected item
' MoveListboxItem(ListB
....Read More |
Rating
|
|
|
How to clear all controls of a winform or user control?
|
Total Hit (4472) |
Here is the small code snippet to clear most of all controls on your form. This code also take care of containers like group box, panel ... etc.
«code LangId=2»
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ClearControls(Me.Contr
....Read More |
Rating
|
|
|
Subclassing In .NET
|
Total Hit (2039) |
In VB 5 and 6, subclassing was something of a pain. To do it at all you needed a raft of cunning hacks and had to keep a very careful track on which object was subclassing what. All of that pain is removed in .NET with the System.Windows.Forms.NativeWindow class, which makes it almost trivial to pro
....Read More |
Rating
|
|
|
Painting in the MDI Client Area
|
Total Hit (2427) |
Although the .NET Framework Form allows you to set a background bitmap or color for the MDI Client area, there's no direct way to draw onto the area to customise it. This sample demonstrates how to create an object which derives from NativeWindow to intercept the messages from the MDI Client area an
....Read More |
Rating
|
|
|
ConsoleAttributes
|
Total Hit (1896) |
The ConsoleAttributes allows you to change the default behaviour of the console class. You can modify several attributes (like ForeColor, BackColor, Echo Input etc), and you can move the cursor around.
|
Rating
|
|
|
Controlling scrolling with the API
|
Total Hit (2622) |
In certain circumstances, we need to be able to control the scroll bars from our code. This may seem like it should be easily done with standard methods when in fact they are buried in the API. I will tell you how I solved this problem in the application I am working on.
....Read More |
Rating
|
|
|
Real Time syntax highlighting [wrapper class]
|
Total Hit (2653) |
Hello again. This time I wanted to bring you something that was really challenging for me to build. I must have tried at least four totally different solutions to this problem consuming literally days of my time until I reached the best one. At the request of our beloved staff, I will attempt to exp
....Read More |
Rating
|
|