Imports Infragistics.Win
Imports System.Data.SqlClient
Imports Infragistics.Win.UltraWinGrid
Public Class Form1
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim dr As DataRow
Dim binding As BindingManagerBase
Dim dt As DataTable
Dim connstring As SqlConnection = New SqlConnection(alarm.My.Settings.con)
Dim band As BandsCollection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'AHMADDataSet.person' table. You can move, or remove it, as needed.
Me.PersonTableAdapter.Fill(Me.AHMADDataSet.person)
'dt = New DataTable()
adapter.SelectCommand = New SqlCommand("SELECT id ,name,fathername,address,marks,rollno,qualification FROM person", connstring)
'DataGridView1.DataSource = dt
'UltraGrid1.DataSource = dt
'dt.Columns(2).ColumnMapping = MappingType.Hidden
'...........................................................................................
adapter.Fill(ds)
'dt.Columns(1).Caption = "hello hello"
'adapter.Fill(dt)
'................................................binding code...................................................
BindControls()
binding = BindingContext(ds.Tables(0))
binding.Position = 0
UltraGrid1.DataSource = ds.Tables(0)
'...............................................................................................
'Me.UltraGrid1.DisplayLayout.AddNewBox.BorderStyle = UIElementBorderStyle.TwoColor
'Me.UltraGrid1.DisplayLayout.AddNewBox.Appearance.BackColor = Color.Pink
'..........................................................................
'background color of grid you set in this way
Me.UltraGrid1.DisplayLayout.Appearance.BackColor = Color.Gold
'..............................................................................
'Dim col As UltraGridColumn
'For Each col In Me.UltraGrid1.DisplayLayout.Bands(0).Columns
' col.Header.Appearance.BackColor = Color.Purple
' ' ' Here we "turn off" theming for the column header.
' 'col.Header.Appearance.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent
' 'col.Header.Appearance.BackColorDisabled = Color.PaleGreen
'Next
'.................NAME OF HEADER OF ULTRA GRID and set the specfic header color change..........................
'Me.UltraGrid1.Text = "Test Grid"
'Me.UltraGrid1.DisplayLayout.Bands(0).Columns("name").Header.Appearance.BackColor = Color.LightGoldenrodYellow
''.......................................
' header position are cahnge in this way
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("fathername").Header.VisiblePosition = 4
''.................set the specfic coloumn color change...........................................
'Me.UltraGrid1.Rows(3).Cells(2).Appearance.BackColor = Color.Orange
''..........................set the specfic active coloumn color change...........................
'Me.UltraGrid1.Rows(3).Cells(3).ActiveAppearance.BackColor = Color.Silver
'//////////////////////////////////////////////////////////////////////////
'Me.UltraGrid1.Rows(3).Cells(1).SelectedAppearance.BackColor = Color.Violet
Me.UltraGrid1.DisplayLayout.Bands(0).Override.AllowDelete = DefaultableBoolean.False
'Me.UltraGrid1.DisplayLayout.Bands(0).Columns(0).CellActivation = Activation.Disabled
'Me.UltraGrid1.DisplayLayout.Bands(0).Columns(1).CellActivation = Activation.Disabled
'Me.UltraGrid1.DisplayLayout.Bands(0).Columns(2).CellActivation = Activation.Disabled
'Me.UltraGrid1.DisplayLayout.Bands(0).Columns(3).CellActivation = Activation.Disabled
'Me.UltraGrid1.DisplayLayout.Bands(0).Columns(4).CellActivation = Activation.Disabled
'Me.UltraGrid1.DisplayLayout.Bands(0).Columns(5).CellActivation = Activation.Disabled
'Me.UltraGrid1.DisplayLayout.Bands(0).Columns(6).CellActivation = Activation.Disabled
'//////////////////////////////////////// remove default selection of first row/////////////////////////////////
UltraGrid1.DisplayLayout.Override.ActiveCellAppearance.Reset()
UltraGrid1.DisplayLayout.Override.ActiveRowAppearance.Reset()
'/////////////ADD BANDS IN ULTRAGRID CODE IS HERE//////////////////////////////////////////
Me.UltraGrid1.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy
'Me.UltraGrid1.DisplayLayout.Bands(0).SortedColumns.Add("name", False, True)
Me.UltraGrid1.DisplayLayout.Bands(0).SortedColumns.Add("fathername", False, True)
Me.UltraGrid1.Rows.ExpandAll(True)
'////////////////////CODE FOR ADD BANDS IN ULTRAGRID CODE IS END HERE/////////////////////////////////////////
End Sub
Private Sub BindControls()
UltraTextEditor1.DataBindings.Add("Text", ds.Tables(0), "id")
UltraTextEditor2.DataBindings.Add("Text", ds.Tables(0), "name")
UltraTextEditor3.DataBindings.Add("Text", ds.Tables(0), "fathername")
UltraTextEditor4.DataBindings.Add("text", ds.Tables(0), "address")
UltraTextEditor5.DataBindings.Add("text", ds.Tables(0), "marks")
UltraTextEditor6.DataBindings.Add("Text", ds.Tables(0), "rollno")
UltraTextEditor7.DataBindings.Add("Text", ds.Tables(0), "qualification")
End Sub
Private Sub UltraButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton1.Click
adapter.InsertCommand = New SqlCommand("INSERT INTO person (name,fathername,address,marks,rollno,qualification) " & "VALUES (@name,@fathername,@address,@marks,@rollno,@qualification)", connstring)
adapter.InsertCommand.Parameters.Add("@name", SqlDbType.NVarChar, 15, "name")
adapter.InsertCommand.Parameters.Add("@fathername", SqlDbType.NVarChar, 15, "fathername")
adapter.InsertCommand.Parameters.Add("@address", SqlDbType.NVarChar, 100, "address")
adapter.InsertCommand.Parameters.Add("@marks", SqlDbType.Int, 15, "marks")
adapter.InsertCommand.Parameters.Add("@rollno", SqlDbType.Int, 15, "rollno")
adapter.InsertCommand.Parameters.Add("@qualification", SqlDbType.NVarChar, 100, "qualification")
adapter.UpdateCommand = New SqlCommand("UPDATE person SET name=@name,fathername=@fathername,address=@address,marks=@marks,rollno=@rollno,qualification=@qualification " & "WHERE id = @id", connstring)
adapter.UpdateCommand.Parameters.Add("@id", SqlDbType.Int, 15, "id")
adapter.UpdateCommand.Parameters.Add("@name", SqlDbType.NVarChar, 15, "name")
adapter.UpdateCommand.Parameters.Add("@fathername", SqlDbType.NVarChar, 15, "fathername")
adapter.UpdateCommand.Parameters.Add("@address", SqlDbType.NVarChar, 100, "address")
adapter.UpdateCommand.Parameters.Add("@marks", SqlDbType.Int, 15, "marks")
adapter.UpdateCommand.Parameters.Add("@rollno", SqlDbType.Int, 15, "rollno")
adapter.UpdateCommand.Parameters.Add("@qualification", SqlDbType.NVarChar, 100, "qualification")
adapter.DeleteCommand = New SqlCommand("DELETE FROM person WHERE id = @id", connstring)
adapter.DeleteCommand.Parameters.Add("@id", SqlDbType.Int, 15, "id")
adapter.Update(ds)
End Sub
Private Sub UltraButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton2.Click
'/////////FOR GO ON THE FIRST RECORD CODE START HERE//////////////////////////////////////////
UltraGrid1.Rows(0).Selected = True
binding.Position = 0
'//////////FOR GO ON THE FIRST RECORD CODE END HERE //////////////////////
End Sub
Private Sub UltraButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton3.Click
'/////////FOR GO ON THE LAST RECORD CODE START HERE//////////////////////////////////////////
UltraGrid1.Rows(0).Selected = True
binding.Position = binding.Count - 1
'/////////FOR GO ON THE LAST RECORD CODE END HERE//////////////////////////////
End Sub
Private Sub UltraButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton5.Click
'////////FOR GO ON THE PREVIOUS RECORD CODE START HERE///////////////////
binding.Position = binding.Position - 1
'//////////////FOR GO ON THE PREVIOUS RECORD CODE END HERE///////////////////////
End Sub
Private Sub UltraButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton4.Click
'////////FOR GO ON THE NEXT RECORD CODE START HERE///////////////////
binding.Position = binding.Position + 1
'////////FOR GO ON THE NEXT RECORD CODE END HERE///////////////////
End Sub
Private Sub UltraButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton6.Click
' //////// FOR ADD NEW RECORD/ OR ADD NEW ROW HERE CODE START HERE///////////////
Dim dr As DataRow = ds.Tables(0).NewRow()
ds.Tables(0).Rows.Add(dr)
binding.Position = binding.Count - 1
' //////// FOR ADD NEW RECORD/ OR ADD NEW ROW HERE CODE END HERE///////////////
End Sub
'set the color of selected rows..........................................................................................
Private Sub UltraGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UltraGrid1.Click
'///////FOR CHANGE THE COLOR OF DEFAULT BLUE COLOR OF SELECTED ROW CODE START HERE///////
Me.UltraGrid1.DisplayLayout.Override.ActiveRowAppearance.BackColor = Color.Green
'//////FOR CHANGE THE COLOR OF DEFAULT BLUE COLOR OF SELECTED ROW CODE END HERE
End Sub
Private Sub UltraGrid1_ClickCell(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ClickCellEventArgs) Handles UltraGrid1.ClickCell
'Me.UltraGrid1.Rows(3).Cells(1).SelectedAppearance.BackColor = Color.Violet
End Sub
Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
'////////FOR ADD VALUE LIST CODE IS START HERE//////////////////////////////////
Dim vl As ValueList
If (Not e.Layout.ValueLists.Exists("MyValueList")) Then
vl = e.Layout.ValueLists.Add("MyValueList")
vl.ValueListItems.Add("AHMAD", "AHMAD")
vl.ValueListItems.Add("WASIM", "WASIM")
vl.ValueListItems.Add("RASHID", "RASHID")
vl.ValueListItems.Add("Misbah", "Misbah")
vl.ValueListItems.Add("HANAN", "HANAN")
vl.ValueListItems.Add("huma", "huma")
vl.ValueListItems.Add("rahil", "rahil")
vl.ValueListItems.Add("RAHUL", "RAHUL")
vl.ValueListItems.Add("USMAN", "USMAN")
vl.ValueListItems.Add("WALID", "WALID")
vl.ValueListItems.Add("JAVED", "JAVED")
vl.ValueListItems.Add("CYRUS", "CYRUS")
vl.ValueListItems.Add("ZAIGUM", "ZAIGUM")
vl.ValueListItems.Add("AMNA", "AMNA")
vl.ValueListItems.Add("HIRA", "HIRA")
vl.ValueListItems.Add("NASIR", "NASIR")
vl.ValueListItems.Add("FAROOQ", "FAROOQ")
vl.ValueListItems.Add("NAYYARA", "NAYYARA")
vl.ValueListItems.Add("AZAM", "AZAM")
vl.ValueListItems.Add("ALVI", "ALVI")
vl.ValueListItems.Add("CYRUS", "CYRUS")
vl.ValueListItems.Add("ZAIGUM", "ZAIGUM")
vl.ValueListItems.Add("Saood", "Saood")
vl.ValueListItems.Add("Fatima", "Fatima")
vl.ValueListItems.Add("Khalid", "Khalid")
vl.ValueListItems.Add("Hassan", "Hassan")
vl.ValueListItems.Add("Raza", "Raza")
vl.ValueListItems.Add("ANUM", "ANUM")
vl.ValueListItems.Add("Moosa", "Moosa")
vl.ValueListItems.Add("fahad", "fahad")
vl.ValueListItems.Add("naheed", "naheed")
vl.ValueListItems.Add("Iram", "Iram")
vl.ValueListItems.Add("RABIYYA", "RABIYYA")
vl.ValueListItems.Add("WAQAS", "WAQAS")
vl.ValueListItems.Add("ASHRAF", "ASHRAF")
vl.ValueListItems.Add("AMIR", "AMIR")
End If
e.Layout.Bands(0).Columns("name").ValueList = e.Layout.ValueLists("MyValueList")
'//////////////////FOR ADD VALUE LIST CODE IS END HERE
e.Layout.Bands(0).Columns(1).CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly
e.Layout.Bands(0).Columns(1).CellAppearance.ForeColor = Color.Blue
e.Layout.Bands(0).Columns(1).CellAppearance.FontData.Underline = Infragistics.Win.DefaultableBoolean.True
e.Layout.Bands(0).Columns(1).CellAppearance.Cursor = Cursors.Hand
End Sub
'................................................................................................................................
Private Sub UltraGrid1_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles UltraGrid1.InitializeRow
'//////////////////////////////Set the background color of ultragrid/////////////////////////////////////.........................
e.Row.Appearance.BackColor = Color.Brown
'.................................................................................................................................
'/////////////////////////////set the fore color of ultragrid////////////////////////////////////////////.........................
e.Row.Appearance.ForeColor = Color.HotPink
'......................................................................
'...............................hide the id coloumn...................................................
'UltraGrid1.DisplayLayout.Bands(0).Columns(0).Hidden = True
Me.UltraGrid1.DisplayLayout.Bands(0).Columns(0).SortIndicator = SortIndicator.Descending
e.Row.ExpandAll()
'////////////////// part for add hyperlink in ultragrid///////////////////enter coloumn name for serach here 2=fathername and in e.Row.Cells(1)=where the location of hyperlink here name=1
e.Row.Cells(1).Tag = "http://www.google.com/search?hl=en&q=" + e.Row.Cells(2).Value.ToString.Replace(" ", "+")
'///////////////part for add hyperlink in ultragrid///////////////
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("name").Style = ColumnStyle.Button
Dim row As UltraGridRow
For Each row In Me.UltraGrid1.Rows
'row.ToolTipText = String.Format("Sample tool tip for {0} index row.", row.Index)
' Tool tip can be set on individual cells as well.
row.Cells(0).ToolTipText = String.Format("coloumn id for {0} index row.", row.Index)
row.Cells(1).ToolTipText = String.Format("coloumn name for {0} index row.", row.Index)
row.Cells(2).ToolTipText = String.Format("coloumn fathername for {0} index row.", row.Index)
row.Cells(3).ToolTipText = String.Format("coloumn address for {0} index row.", row.Index)
row.Cells(4).ToolTipText = String.Format("coloumn marks for {0} index row.", row.Index)
row.Cells(5).ToolTipText = String.Format("coloumn rollno for {0} index row.", row.Index)
row.Cells(6).ToolTipText = String.Format("coloumn qualification for {0} index row.", row.Index)
Next
End Sub
Private Sub UltraButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton7.Click
Dim index As Integer
Try
connstring.Open()
Dim myQyery As String = "SELECT * FROM [person] WHERE ([name] = '" + UltraTextEditor8.Text + "')"
adapter = New SqlDataAdapter(myQyery, connstring)
Dim dt As New DataTable
adapter.Fill(dt)
If dt.Rows.Count <= 0 Then
' MsgBox("This name Does Not Exist", MsgBoxStyle.DefaultButton1, "Not Exist")
MsgBox("WARNING! This name Does Not Exist please enter the correct name")
Else
UltraGrid1.DataSource = dt
index = UltraGrid1.ActiveRow.Index
UltraTextEditor1.Text = dt.Rows()(1).ToString
UltraTextEditor2.Text = dt.Rows(index)(2).ToString
UltraTextEditor3.Text = dt.Rows(index)(3).ToString
UltraTextEditor4.Text = dt.Rows(index)(4).ToString
UltraTextEditor5.Text = dt.Rows(index)(5).ToString
UltraTextEditor6.Text = dt.Rows(index)(6).ToString
UltraTextEditor7.Text = dt.Rows(index)(7).ToString
End If
Catch ex As Exception
MsgBox("you name is MET suceessfully")
Finally
connstring.Close()
End Try
End Sub
Private Sub UltraButton8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton8.Click
'If Me.UltraGrid1.Selected.Rows.Count > 0 Then
' ' Delete the selected rows by calling DeleteSelectedRows.
' Me.UltraGrid1.DeleteSelectedRows()
' Else
' ' Show a message if there are no selected rows.
' MessageBox.Show("There are no rows selected. Select rows first.")
' End If
'Me.UltraGrid1.Selected.Rows.Clear()
'Me.UltraTextEditor1.Text = "*cleared*"
'UltraGrid1.DeleteSelectedRows(True)
'////////DELETE BUTTON CODE SELECTED ROW START HERE///////////
Dim row As UltraGridRow
For Each row In Me.UltraGrid1.Selected.Rows
row.Delete(False)
Me.UltraGrid1.UpdateData()
Next
'////////DELETE BUTTON CODE SELECTED ROW END HERE///////////
End Sub
Private Sub UltraGrid1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles UltraGrid1.KeyPress
End Sub
'////////////////// hyper link code is there and some part is above////////////////
Private Sub UltraGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles UltraGrid1.MouseDown
Dim objClickedElement As UIElement = Me.UltraGrid1.DisplayLayout.UIElement.ElementFromPoint(UltraGrid1.PointToClient(Form1.MousePosition))
If objClickedElement Is Nothing Then Return
Dim objCellElement As CellUIElement = objClickedElement.GetAncestor(GetType(Infragistics.Win.UltraWinGrid.CellUIElement))
If objCellElement Is Nothing Then Return
Dim objCell As UltraGridCell = CType(objCellElement.GetContext(GetType(UltraGridCell)), UltraGridCell)
If objCell Is Nothing Then Return
'/////////////name here as key/////////////
If objCell.Column.Key = "name" Then
System.Diagnostics.Process.Start(objCell.Tag.ToString)
End If
'/////hyper link code is there and some part is above is end there//////////
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'UltraGrid1.Rows.Refresh(Infragistics.Win.UltraWinGrid.RefreshRow.ReloadData)
UltraGrid1.Rows.Refresh(Infragistics.Win.UltraWinGrid.RefreshRow.RefreshDisplay)
End Sub
Private Sub Display_ToolTips_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Set tool tip on a header column.
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("id").Header.ToolTipText = "field contain user id ."
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("name").Header.ToolTipText = "field contains user name ."
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("fathername").Header.ToolTipText = " field contains user fathername ."
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("address").Header.ToolTipText = "field contains user address."
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("marks").Header.ToolTipText = "field contains user marks ."
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("rollno").Header.ToolTipText = "field contains user rollno ."
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("qualification").Header.ToolTipText = "field contains user qualification "
' Set tool tip on a row.
'Me.UltraGrid1.Rows(0).Cells(1) = "This is a row tool tip."
' Set tool tip on a cell.
'Me.UltraGrid1.Rows(0).Cells(1).ToolTipText = "This is a cell tool tip."
' Add a summary.
Dim summary As SummarySettings = _
Me.UltraGrid1.DisplayLayout.Bands(0).Summaries.Add("count", _
SummaryType.Count, _
Me.UltraGrid1.DisplayLayout.Bands(0).Columns(0), _
SummaryPosition.UseSummaryPositionColumn)
' Set the tooltip on the summary settings object. This tool tip will
' be displayed on every summary value instance associated with this
' summary settings object.
summary.ToolTipText = String.Format("Count of column {0}.", summary.SourceColumn.Header.Caption)
' Tooltip can be set on individual summary value objects as well, in case you
' want to display a different tool tip based on the calculated value. A good place
' to set such summary value specific tool tips is in SummaryValueChanged event.
Me.UltraGrid1.Rows.SummaryValues("count").ToolTipText = _
String.Format("Count of column {0}.", summary.SourceColumn.Header.Caption)
End Sub
End Class
No comments:
Post a Comment