i have a datagridview which i populate from a SQL database.
one of the columns is of a Ntext type. i would like to enlarge the cell on focus so the user would be able to read what's in it without entering edit mode.
any idea ?
i have a datagridview which i populate from a SQL database.
one of the columns is of a Ntext type. i would like to enlarge the cell on focus so the user would be able to read what's in it without entering edit mode.
any idea ?
iunderstand that however if i will not assign that value to index then the first row index would be 0 and not 1 and it's kind of confusing
I would like to insert my panel at the top, when I do so now the dgv will cover half of the panel, how do I solve that?
Private Sub grdSize()
Me.grdAccountTypes.Width = 0
Me.grdAccountTypes.Height = 0
For Each column As DataGridViewColumn In Me.grdAccountTypes.Columns
Me.grdAccountTypes.Width += column.Width
Next
Me.grdAccountTypes.Width += Me.grdAccountTypes.RowHeadersWidth
For Each Rows As DataGridViewRow In Me.grdAccountTypes.Rows
Me.grdAccountTypes.Height += Rows.Height + 1.55
Next
Me.grdAccountTypes.Height += Me.grdAccountTypes.ColumnHeadersHeight
End Sub
issue has to do with the number of rows which I represent
The first row in the dB is 0, so to prevent confusions I added 1 to the index so row 0 will be represented as row 1. The issue is that when I scroll down I “gain” a row, and the last row will be presented as row 23, though I actually have only 22 records.
Public Sub grdMouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs)
Try
If e.Delta > 0 Then
Dim index As Integer
index = grdAccountTypes.CurrentRow.Index + 1
grdAccountTypes.DataSource.moveprevious()
grdAccountTypes.Select()
lblCRM.Text = index.ToString
ElseIf (e.Delta < 0) Then
Dim index As Integer
index = grdAccountTypes.CurrentRow.Index + 1 + 1
grdAccountTypes.Select()
grdAccountTypes.DataSource.MoveNext()
lblCRM.Text = index.ToString
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
I am trying to delete a row and update the database, i wrote the code, but it results in an error:
Dynamic SQL generation for the updatecommand is not supported against a selectcommand that does not return and key column information.
the SQL table contains a primary key, any idea ?
grdAccountTypes.Rows.Remove(grdAccountTypes.CurrentRow)
dataAdapter.Update(CType(Me.bindingSource1.DataSource, DataTable))
bindingSource1.DataSource.AccountTypse.acceptchanges()
MessageBox.Show("Update successful")
i need to create a vertical seperation line in a panel, how do i do so ?
do i need to create a place holder and just load an image or is there a better way for doing so ?
guys, where can i find some icons needed for a panel ?
i am looking for the regular icons, add, delete, save etc ?
It Did not work.... Permission error Help
which means you can't connect to your database
did you modify the code to connect to your DB ?
Hi guys,
i created a panel with few buttons, all buttons have the same size, most buttons hold images, 2 of them hold string (1 or 2 digit)
the string buttons will not align with the rest of them, and i have no idea why ?
anyone ?
Public Class AccountTypes
Inherits System.Windows.Forms.Form
Private grdAccountTypes As New DataGridView()
Private bindingSource1 As New BindingSource()
Private dataAdapter As New SqlDataAdapter()
Private CurrentRow As New DataGridViewRow()
' Declare Form Componantes
Private WithEvents btnReload As New Button()
Private WithEvents btnSubmit As New Button()
Private WithEvents btnDelete As New Button()
Private WithEvents btnAddRecord As New Button()
' Record Nav Buttons
Private WithEvents btnNextRow As New Button()
Private WithEvents btnLastRow As New Button()
Private WithEvents btnPreviousRow As New Button()
Private WithEvents btnFirstRow As New Button()
' Labels
Private WithEvents lblRowCounter As New Label()
Private WithEvents lblof As New Label()
Private WithEvents lblRecords As New Label()
Private WithEvents lblCRM As New Label() ' CRM Current Row Number
' Tooltip
Private WithEvents toolTip1 As System.Windows.Forms.ToolTip
' Initialize the form.
Public Sub New()
' Button Size Variables
Dim X, Y As Integer
X = 24
Y = 24
' DataGridView Style Definitions
grdAccountTypes.Dock = DockStyle.None
grdAccountTypes.ScrollBars = ScrollBars.None
grdAccountTypes.MultiSelect = False
grdAccountTypes.SelectionMode = DataGridViewSelectionMode.FullRowSelect
'Declare form buttons
'reload Button
Me.btnReload.Size = New Size(X, Y)
Me.btnReload.Image = Image.FromFile("C:\Yugo\reload16.png")
'Submit Button'
Me.btnSubmit.Image = Image.FromFile("C:\yugo\submit.png")
Me.btnSubmit.Size = New Size(X, Y)
'Delete Button
Me.btnDelete.Size = New Size(X, Y)
Me.btnDelete.Image = Image.FromFile("C:\Yugo\delete.png")
'Add Record Button
btnAddRecord.Image = Image.FromFile("C:\Yugo\deleteblack.png")
Me.btnAddRecord.Size = …
that's what i was using
as i said the tooltip show's the color doesn't change
i am trying to change the background color of a tooltip
i am using tooltip.backgroundcolor = color.colr
no errors but thecolor doesn't change
any ideas ?
but i have noticed that if i would use the .MoveNext
i don't need to use all the rest
i can also use MovePrevious, Move.First, MoveLast.
there is one minor issue the selection indicator the black arrow stays at the first row.
i am trying to create a nextrow button to work with a bound datagridview
the problems i have:
1. the row moves down, but the first row is the one who has the focus (the little black triangle is staying to it's left.
2. i am trying to set a condition, and that is if the index = the row before last (last row is always empty in a datagridview) then select the row before last.
3. please try and explain what am i doing wrong - i am a newbie
i am getting an index overflow
Private Sub btnNextRow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNextRow.Click
Dim iTest As Integer
Dim LastRow
LastRow = grdAccountTypes.Rows.Count
grdAccountTypes.SelectionMode = DataGridViewSelectionMode.FullRowSelect
Try
If iTest >= LastRow Then
iTest = grdAccountTypes(0, 0).Selected = True
Else
iTest = grdAccountTypes.SelectedRows(0).Index + 1
grdAccountTypes.Rows(iTest).Selected = True
End If
' If iTest = LastRow Then
' grdAccountTypes(0, LastRow).Selected = False
' End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
it actually works kind of,
i have one more question for you, i would like to stop the dgv from scrolling in both end,
so i did modify the Select new row event and i can stop the scroll at the bottom.
what i don't understand how to do is to stop the grid from circling at the top
Public Sub SelectNewRow(ByVal RowIndex As Integer)
Dim LastRow As Integer
LastRow = grdAccountTypes.Rows.Count() - 1
If grdAccountTypes.RowCount = 0 Then ' if no row exist right now
MessageBox.Show("No row existed right now. Please add some records")
Else
If RowIndex >= grdAccountTypes.Rows.Count() - 1 Then
grdAccountTypes(0, LastRow).Selected = True
ElseIf RowIndex < 0 Then
grdAccountTypes(0, grdAccountTypes.Rows.Count() - 1).Selected = True
Else
grdAccountTypes(0, RowIndex).Selected = True
End If
End If
End Sub
guys i have an issue with scrolling a datagridview (VB.Net 2010) using the mouse wheel
i created a mousewheel event an i am catching the mouse-wheel movement up or down
i created a scroll event and set the boundaries for the scroll, but i have no idea how to combine both procedures:
Mouse wheel event
Public Sub grdMouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim RowIndex As Integer = grdAccountTypes.CurrentRow.Index
If e.Delta < 0 Then
MessageBox.Show("Mouse wheel is being moved down")
Else
'RowIndex = grdAccountTypes.CurrentRow.Index + 1
'RowIndex = grdAccountTypes.FirstDisplayedScrollingRowIndex Then
' grdAccountTypes(0, 0).Selected = True
MessageBox.Show("Mouse wheel is being moved up")
End If
Scroll Event
Public Sub grdScroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs)
Dim RowIndex As Integer = grdAccountTypes.CurrentRow.Index + e.NewValue
If grdAccountTypes.RowCount = 0 Then ' if no row exist right now
MessageBox.Show("No row existed right now. Please add some records")
ElseIf RowIndex = grdAccountTypes.Rows.Count() - 1 Then
grdAccountTypes(0, 0).Selected = True
Else
grdAccountTypes(0, RowIndex).Selected = True
End If
End Sub
any help would be appreciated