2008-03-01

CheckedListBox

Sample Code

Add Object to CheckedListBox

Dim pItem As CarItem

pItem = New CarItem()
pItem.CarId = 1
pItem.CarName="CarName"

' Add this object to CheckListBox
' And CheckListBox show CarName because I override toString function
Me.CheckListBox1.Items.Add(pItem, True)

' Class CarItem

Private Class CarItem

Public CarId As Integer
Public CarName As String

Public Sub New()

End Sub

' Override tostring
Public Overrides Function ToString() As String
Return CarName
End Function

End Class



Get status items in CheckedListBox

For i As Integer = 0 To Me.CheckedListBox.Items.Count - 1
If Me.CheckedListBox.GetItemChecked(i) Then
'TODO Something

End If
Next i

Get only Checked Items

For i As Integer = 0 To Me.CheckedListBox.CheckedItems.Count - 1
'TODO Something
Next



Set all item checked

For i As Integer = 0 To Me.CheckedListBox.Items.Count-1
Me.CheckedListBox.SetItemChecked(i, true)

Next i

2008-02-23

Windows Controls

Controls

A control is an object that can be drawn on to the Form to enable or enhance user interaction with the application. Examples of these controls, TextBoxes, Buttons, Labels, Radio Buttons, etc. All these Windows Controls are based on the Control class, the base class for all controls. Visual Basic allows us to work with controls in two ways: at design time and at runtime. Working with controls at design time means, controls are visible to us and we can work with them by dragging and dropping them from the Toolbox and setting their properties in the properties window. Working at runtime means, controls are not visible while designing, are created and assigned properties in code and are visible only when the application is executed. There are many new controls added in Visual Basic .NET and we will be working with some of the most popular controls in this section. You can select the controls from the menu towards the left-hand side of this page.

Notable properties of most of these Windows Controls which are based on the Control class itself are summarized in the table below. You can always find the properties of the control with which you are working by pressing F4 on the keyboard or by selecting View->Properties Window from the main menu.

The Control Class

The Control class is in the System.Windows.Forms namespace. It is a base class for the Windows Controls. The class hierarchy is shown below.

Object
MarshalByRefObject
Component
Control
ButtonBase, Etc, Etc
Button, Etc, Etc

Main class is the Object class from which MarshalByRefObject class is derived and the Component class is derived from the MarshalByRefObject class and so on.

The properties of the Control object are summarized below. Properties are alphabetical as seen in the properties window.


PropertyDescription
AllowDropIndicates if the form can accept data that the user drags and drops into it
AnchorGets/Sets which edges of the control are anchored
BackColorGets/Sets the background color for the control
BackgroundImageGets/Sets the background image in the control
BottomGets the distance bewteen the bottom of the control and the top of its container client area
BoundsGets/Sets the controls bounding rectangle
CanFocusReturns a value specifying if the control can recieve focus
CanSelectReturns a value specifying if the control can be selected
CaptureGets/Sets a value specifying if the control has captured the mouse
CausesValidationGets/Sets a value specfying if the control causes validation for all controls that require validation
ContainsFocusReturns a value specifying if the control has the input focus
ContextMenuGets/Sets the shortcut menu for the control
ControlsGets/Sets the collection of controls contained within the control
CursorGets/Sets the cursor to be displayed when the user moves the mouse over the form
DataBindingsGets the data bindings for the control
DockGets/Sets which edge of the parent a control is docked to
EnabledGets/Sets a value indicating if the control is enabled
FocusedReturns a value specifying if the control has input focus
FontGets/Sets the font for the control
ForeColorGets/Sets the foreground color of the control
HasChildrenReturns a value specifying if the control contains child controls
HeightGets/Sets the height of the control
LeftGets/Sets the x-coordinates of a control's left edge in pixels
LocationGets/Sets the co-ordinates of the upper-left corner of the control
NameGets/Sets name for the control
ParentGets/Sets the control's parent container
RightReturns the distance between the right edge of the control and the left edge of it's container
RightToLeftGets/Sets the value indicating if the alignment of the control's elements is reversed to support right-to-left fonts
SizeGets/Sets size of the control in pixels
TabIndexGets/Sets the tab order of this control in its container
TabStopGets/Sets a value specifying if the user can tab to this control with the tab key
TagGets/Sets an object that contains data about the control
TextGets/Sets the text for this control
TopGets/Sets the top coordinates of the control
VisibleGets/Sets a value specifying if the control is visible
WidthGets/Sets the width of the control


Control Tab Order

To move focus from one control to other quickly using the keyboard we can use the Tab key. We can set the order in which the focus is transferred by setting the tab order. The tab order is the order in which controls on the form receive the focus and is specified by the TabIndex property. To change the order in which a control receives focus we need to set the TabIndex property to different value for each control on the form. Lower values receive the focus first and proceed numerically through higher values. If there is a tie between TabIndex values, the focus first goes to the control that is closest to the front of the form.
We can also set the tab order graphically with Visual Studio by selecting Tab Index from the View menu. Boxes containing current tab order appear in each control when you select Tab Index from View menu. Click each control to set the correct tab order in which you want the controls to receive focus.

Ref: www.startvbdotnet.com

2008-01-15

Check Database Memory

When I use the TaskPad in Enterprise Manager to check a database's allocated, used, and free space (as reported on the General tab), the values I see don't match the values I get when I use the sp_HelpDB and sp_Spaceused stored procedures. For example, when I checked one of my databases today, I got the following information:

  • In TaskPad, Enterprise Manager reported that the database had 211549.75MB of allocated space, 110294.44MB of used space, and 101255.31MB of free space.
  • For the same database, the sp_Spaceused stored procedure told me I had 212113.50MB of allocated space and 19541.14MB of unallocated space.
  • The sp_helpDB stored procedure reported that I had an MDF file size of 211549.75MB.

Can I use T-SQL to return the same information that I see when I use the TaskPad?

To generate the information on the TaskPad, Enterprise Manager uses a combination of the following four queries.

EXEC sp_spaceused
SELECT fileid, name, filename, size, growth, status, maxsize
FROM dbo.sysfiles WHERE (status & 0x40) <>0
DBCC sqlperf(logspace)
DBCC showfilestats

Enterprise Manager uses SQL-DMO to retrieve the information. . . .

Content by Microsoft's SQL Server Development Team Ask Microsoft

2007-12-21

Internet Explorer 8

Internet Explorer 8

Just as he was the first to talk about IE7, Bill Gates kept the tradition alive and discussed IE8 at the Mix ‘n Mash event here on campus yesterday. Bill was talking to some bloggers about IE.Next and called it IE8, the same way we do here in the IE team hallway.

So, yes, the version after IE7 is IE8. We looked at a lot of options for the product name. Among the names we considered and ruled out:

IE 7+1
IE VIII
IE 1000 (think binary)
IE Eight!
iIE
IE for Web 2.0 (Service Pack 2)
IE Desktop Online Web Browser Live Professional Ultimate Edition for the Internet (the marketing team really pushed for this one ;-)
Ie2.079 (we might still use this for the Math Major Edition)

Of course, some people care about other aspects of IE8 much more than they care about the name. As I’ve walked different people through the plan, I’ve gotten “Does it have feature X?” “When is the beta?” “When does it release” and even the more thoughtful “What are you trying to accomplish with this release?”

You will hear a lot more from us soon on this blog and in other places. In the meantime, please don’t mistake silence for inaction.

Thank you ieblog
Dean Hachamovitch
General Manager
Published Wednesday, December 05, 2007 2:33 PM by ieblog