Wednesday, June 30, 2004
DataGrid Help 2 -- Windows Form VB.NET
Create the Sample
Follow these steps to create a new Visual Basic Windows Application project:
Start Microsoft Visual Studio .NET.
On the File menu, point to New, and then click Project.
In
the New Project dialog box, click Visual Basic Project under Project
Types, and then click Windows Application under Templates. By default,
Form1 is added.
Drag a DataGrid control from the toolbox to Form1.
Add the following code to the top of the code window in the Declarations section of Form1.vb:
Imports System.Data.SqlClient
Imports System.Windows.Forms
Add the following code after the "Windows Form Designer generated code" section of the code window:
Public MyCombo As New ComboBox()
Dim con As New SqlConnection("server=myservername;uid=myid;pwd=mypassword;database=northwind")
Dim daEmp As New SqlDataAdapter("Select * From Employees", con)Public ds As New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler MyCombo.TextChanged, AddressOf Ctrls_TextChanged
'Fill ComboBox list.
MyCombo.Name = "MyCombo"
MyCombo.Visible = False
MyCombo.Items.Clear()
MyCombo.Items.Add("Sales Representative")
MyCombo.Items.Add("Inside Sales Coordinator")
MyCombo.Items.Add("Vice President, Sales")
MyCombo.Items.Add("Sales Manager")
MyCombo.Items.Add("Flunky")
daEmp.Fill(ds, "Employees")'Set the RowHeight of the DataGrid to the height of the ComboBox.
DataGrid1.PreferredRowHeight = MyCombo.Height
DataGrid1.DataSource = dsDataGrid1.DataMember = "Employees"
'Add ComboBox to the Control collection of the DataGrid.
DataGrid1.Controls.Add(MyCombo)
End SubPrivate Sub DataGrid1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles DataGrid1.Paint
If DataGrid1.CurrentCell.ColumnNumber = 3 Then
MyCombo.Width = DataGrid1.GetCurrentCellBounds.Width
End If
End SubPrivate Sub Ctrls_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If DataGrid1.CurrentCell.ColumnNumber = 3 Then
MyCombo.Visible = False
If DataGrid1.Item(DataGrid1.CurrentCell) & "" = "" Then
SendKeys.Send("*")
End If
DataGrid1.Item(DataGrid1.CurrentCell) = MyCombo.Text
End If
End Sub
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
If DataGrid1.CurrentCell.ColumnNumber = 3 Then
MyCombo.Visible = False
MyCombo.Width = 0
MyCombo.Left = DataGrid1.GetCurrentCellBounds.Left
MyCombo.Top = DataGrid1.GetCurrentCellBounds.Top
MyCombo.Text = DataGrid1.Item(DataGrid1.CurrentCell) & ""
MyCombo.Visible = True
Else
MyCombo.Visible = False
MyCombo.Width = 0
End If
End SubPrivate Sub DataGrid1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Scroll
MyCombo.Visible = False
MyCombo.Width = 0
End SubPrivate Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
MyCombo.Visible = False
MyCombo.Width = 0
End Sub
Modify the connection string as necessary for your environment.
Press
F5 to run the project. Click one of the fields in the Title column in
the DataGrid. Notice that the ComboBox control is located in the
DataGrid.
Expand the ComboBox. Notice that a list of titles is displayed.
DataGrid Help -- Windows Form VB.NET
Monday, June 28, 2004
Call to Static Methods
Call to Static Methods
You cannot call static method of a class using the object of the class...
You would have to call it using the Class name itself..
eg.You cannot call base class's static method using base.StaticMethod();
that shall result into an error...
the way you do it is:
//Class having Static Method
public class MyClass
{
public static string StaticMethod()
{
return "miteshvmehta@gmail.com";
}
}
//Class using Static Method
public class ClientClass
{
public string GetHelpLineEmailId()
{
return MyClass.StaticMethod();
}
}
Mitesh Mehta
Microsoft Certified Professional .Net
If You Think YOU CAN... You Can...
Choosing a NET Framework Data Provider
Choosing a .NET Framework Data Provider
Depending on the design and data source for your application, your
choice of .NET Framework data provider can improve the performance,
capability, and integrity of your application. The following message
discusses the advantages and limitations of each NET Framework data
provider.
1. .NET Framework Data Provider for SQL Server
Recommended for middle-tier applications using Microsoft SQL Server 7.0 or later.
Recommended for single-tier applications using Microsoft Data Engine (MSDE) or Microsoft SQL Server 7.0 or later.
Recommended over use of the OLE DB Provider for SQL Server (SQLOLEDB) with the .NET Framework Data Provider for OLE DB.
For Microsoft SQL Server version 6.5 and earlier, you must use the
OLE DB Provider for SQL Server with the .NET Framework Data Provider
for OLE DB.
2. .NET Framework Data Provider for OLE DB
Recommended for middle-tier applications using Microsoft SQL Server
6.5 or earlier, or any OLE DB provider that supports the OLE DB
interfaces listed in OLE DB Interfaces Used
by the .NET Framework Data Provider for OLE DB
<cpconoledbinterfacessupportedbyoledbnetdataprovider.htm> (OLE DB 2.5 interfaces are not required).For Microsoft SQL Server 7.0 or later, the .NET Framework Data Provider for SQL Server is recommended.
Recommended for single-tier applications using Microsoft Access
databases. Use of a Microsoft Access database for a middle-tier
application is not recommended.
3. .NET Framework Data Provider for ODBC
Recommended for middle-tier applications using ODBC data sources.
Recommended for single-tier applications using ODBC data sources.
<DIR>Note The .NET Framework Data Provider for ODBC is not included in
the NET Framework version 1.0. If you require the .NET Framework Data
Provider for ODBC and are using the .NET Framework version 1.0, you can
download the .NET Framework Data Provider for ODBC at
http://msdn.microsoft.com/downloads. The namespace for the downloaded
NET Framework Data Provider for ODBC is Microsoft.Data.Odbc.</DIR>
4..NET Framework Data Provider for Oracle
Recommended for middle-tier applications using Oracle data sources.
Recommended for single-tier applications using Oracle data sources.
Supports Oracle client software version 8.1.7 and later.
The .NET Framework Data Provider for Oracle classes are located in the System.Data.OracleClient namespace and are contained in the System.Data.OracleClient.dll assembly. You need to reference both the System.Data.dll and the System.Data.OracleClient.dll when compiling an application that uses the data provider.
<DIR>Note The .NET Framework Data Provider for Oracle is not included in
the .NET Framework version 1.0. If you require the .NET Framework Data
Provider for Oracle and are using the .NET Framework version 1.0, you
can download the .NET Framework Data Provider for Oracle at
http://msdn.microsoft.com/downloads.
Regards
Mitesh Mehta
Tip serialize dataset
How can
I serialize a DataSet object?It's a very good question. DataSet object can be serialized two
different ways. First of all, you can use XmlSerializer, create a serializer
type of DataSet, and then call the Serialize method, as we did in all the
slides, and basically it will serialize the DataSet object. However, DataSet has
its own serializing method developed. Data sets use XmlSerializer class
internally and it has its own methods available. They are called WriteXml
and WriteXmlSchema. So you could use those methods or you could use
XmlSerializer to serialize the dataset.
Wednesday, June 23, 2004
Calculate a Load
Hi All,
A nice article which explains how to Calculate a Load, this would help
to gain insights of calculations and what need to be avoided.
http://www.theserverside.net/articles/showarticle.tss?id=CalculatingLoad
--
Thanks & Regards
Mitesh Mehta
Wednesday, June 09, 2004
.NET CF Resources @ Code Project
.NET CF Resources @ Code Project
Wow... there are a ton of great .NET Compact Framework articles and samples over on Code Project. .NET CF Resources @ Code Project. Check it out! It looks like many of these are the result of a contest that just ended (giving away 5 Pocket PC devices). What other sites do you look at for .NET CF articles and samples?
[Author: Mitesh Mehta]
Easy EmailValidator control
using System;
using System.Web;
using System.Web.UI;
namespace MiteshMehta.Validation
{
/// <summary>
/// Validates an email address
/// </summary>
public class EmailValidator : System.Web.UI.WebControls.RegularExpressionValidator
{
/// <summary>
/// Creates a new instance of the EmailValidator class
/// </summary>
public EmailValidator() : base()
{
this.ValidationExpression = "" +
@"^([a-zA-Z0-9_\-\.']+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
}
}
}
Then you can simply drop it on a web form and set the properties like any other validator:
-----------------------------------------
Easy EmailValidator control
<%@ Page language="c#" Codebehind="MyPage.aspx.cs" AutoEventWireup="false" Inherits="MyProject.MyPage" %>
<%@ Register TagPrefix="Validators" Namespace="AlexCampbell.Validation" Assembly="AlexCampbell" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<body>
<form runat="server">
<asp:TextBox runat="server" ID="emailTextBox" />
<Validators:EmailValidator runat="Server" Display="Dynamic" ControlToValidate="emailTextBox">
Invalid email!
</Validators:EmailValidator>
</form>
</body>
</html>
More on Exchange SP1 and SBS 2003
To make a long story short, we screwed this up. We should have had these problems identified and a workaround/fix available at the time Exchange SP1 came out. I've gotten several rant e-mails from those of you whom I know personally, and you're all 100% right.
Right now, we're working to make sure there aren't any other issues with Exchange SP1. Right now we're working on getting everything wrapped up so you all can have something to fix all this. But here's what you can do right now:
1. For the OWA issue, work around it. Sorry. There's a partial workaround by placing the domain name in the default domain field in IIS, however the OWA cookie auth introduced in 2003 doesn't fully take advantage of this, so you'll still get some weird behavior occasionally. The best thing to do is use DOMAIN\username for the short term.
2. For the alert about store.exe consuming more memory, you can ignore this error. Store.exe is not really taking more memory - in SP1 Exchange changed the method in which certain memory bytes are registered (See my earlier post on this), which triggers this alert, but it's benign. What's probably even best is to just disable the alert altogether. We're actually going back to figure out why we put this alert in in the first place - we're going back to SBS 2000 and there may have been a valid reason back then, but now it just seems like an old alert that got grandfathered in.
You can install Exchange SP1 on SBS, and if you're comfortable with these issues, go right ahead. We're working to get these particular problems cleaned up ASAP, and I'll have more details on that as soon as I can.
Friday, June 04, 2004
Html Templates
http://www.4layouts.com/webmasters/dora1234/zipfiles/1097.zip
http://www.4layouts.com/webmasters/xaruf/zipfiles/619.zip
http://www.4layouts.com/webmasters/britton/zipfiles/1058.zip
http://www.4layouts.com/webmasters/davidx03/zipfiles/1058.zip
http://www.4layouts.com/webmasters/webhomez/zipfiles/1058.zip
http://www.4layouts.com/webmasters/ctemp/zipfiles/1058.zip
http://www.4layouts.com/webmasters/4ewebnet/zipfiles/1058.zip
http://www.4layouts.com/webmasters/abdylas/zipfiles/1058.zip
http://www.4layouts.com/webmasters/wtbiz/zipfiles/1058.zip
http://www.4layouts.com/webmasters/templates911/zipfiles/1058.zip
http://www.4layouts.com/webmasters/tdcaron/zipfiles/1058.zip
http://www.4layouts.com/webmasters/rkaic/zipfiles/
http://curvedspaces.com/