nighttrain's Profile User Rating: -----

Reputation: 8 Worker
Group:
Active Members
Active Posts:
383 (0.25 per day)
Joined:
22-September 10
Profile Views:
5,120
Last Active:
User is offline Dec 02 2014 06:56 AM
Currently:
Offline

Previous Fields

Country:
PL
OS Preference:
Windows
Favorite Browser:
Internet Explorer
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Volkswagen
Dream Kudos:
0
Icon   nighttrain still drilling

Posts I've Made

  1. In Topic: datagridview selected row value id

    Posted 2 Dec 2014

    Any idea? datagridview datasource is dataset.tables(0)

    i tried also with:
     If dgv.CurrentRow.Index = dgv.NewRowIndex - 1 Then
            'User clicked NewRow but CurrentRow is the one before the NewRow
        End If
    
    

    it goes inside if when i click newrow but unfortunetly when i click on row before newrow its also going into if...
  2. In Topic: datagridview selected row value id

    Posted 1 Dec 2014

    anyone has idea how to overcome this issue in diffrent way? If i associate dgv.CurrentRow.IsNewRow to datagrid cellclick event its working correctly. The problem is i have couple button on form for adding, deleting and for other operation so i cannot associate just to cellClick event directly. User can check the row and then click delete button but can also use new row to add new data. Jow to overcome this issue then?
  3. In Topic: datagridview selected row value id

    Posted 30 Nov 2014

    i got new row. hmm, have no idea, i am also aligning grid after is populating but dont think this code can do some cahange to the action we talking about just look:

     dgv.RowsDefaultCellStyle.BackColor = Color.SkyBlue 'LightSkyBlue 'CornflowerBlue               'kolor 1
            dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue   'kolor2
    
    
            '.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize
            '.RowHeadersDefaultCellStyle.Font = New Font("Segoe UI", 10)
            'dgv.CellBorderStyle = DataGridViewCellBorderStyle.None             'bez siatki w celach
    
            dgv.ColumnHeadersBorderStyle = DataGridViewCellBorderStyle.None             'bez siatki w celach
    
    
            Me.dgv.AllowUserToAddRows = True
            'GrdAttributes.Columns["attribute_id"].Visible = false;  don't see a attribute_id :)/>/>
            Me.dgv.DefaultCellStyle.Font = New Font("Tahoma", 9)
    
            Me.dgv.DefaultCellStyle.SelectionForeColor = Color.Red
            Me.dgv.DefaultCellStyle.SelectionBackColor = Color.Yellow
    
            Me.dgv.RowHeadersVisible = False
    
            Dim column0 As DataGridViewColumn = dgv.Columns(0)
            column0.Visible = True
            Dim ColNazwa As DataGridViewColumn = dgv.Columns(1)
            ColNazwa.HeaderText = "Nazwa"
            ColNazwa.[ReadOnly] = False
            Dim ColOpis As DataGridViewColumn = dgv.Columns(2)
            ColOpis.HeaderText = "Opis"
            ColOpis.[ReadOnly] = False
            Dim column3 As DataGridViewColumn = dgv.Columns(3)
            column3.Visible = False
    
            '----potrzebne gdy resizujemy forme grid automatycznie zawsze sie dopasowuje:
            'Anchor ustawiony na top,left,bottom,right !!
            dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
            '----
    
            Dim dgvColumnHeaderStyle As New DataGridViewCellStyle()
            dgvColumnHeaderStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
            dgv.ColumnHeadersDefaultCellStyle = dgvColumnHeaderStyle
    
            'You cannot change the column and row header colours without disabling visual styles:
            dgv.EnableHeadersVisualStyles = False
            ' Set the row and column header styles.
            dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.WhiteSmoke
            dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Firebrick
            dgv.ColumnHeadersDefaultCellStyle.Font = New Font("Tahoma", 14)
    
    


    when i click on last (new row) is showing the same id number as before row id ;/
  4. In Topic: datagridview selected row value id

    Posted 30 Nov 2014

    User selecting row and clicking button to invoke action like below. IsNewRow seems not to work. I am using like this, and even i am selecting new row its going to else clause.
     Private Sub btnUsun_Click(sender As System.Object, e As System.EventArgs) Handles btnUsun.Click
            If dgv.CurrentRow.IsNewRow Then
                MessageBox.Show("Select diffrent row", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Return
            Else
                NewRodzaj.Delete(dgv.CurrentRow.Cells(0).Value)
            End If
        End Sub
    
    
  5. In Topic: Editing Information via Datagridview and Winforms

    Posted 28 Nov 2014

    this code should give you start:

    mports System.Data.SqlClient
    
    Public Class Form1
    '*** Define form level variables so that they are visible from other methods
        Dim tblLocalGroceries As DataTable
        Dim daLocalGroceries As SqlDataAdapter
        Dim dsSupplies As New DataSet
        Dim oCon As SqlConnection
    
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            oCon = New SqlConnection
            oCon.ConnectionString = "Data Source=IPS-03042013\sqlexpress;Initial Catalog=SqlToVbExamples;Integrated Security=True"
            dsSupplies = New DataSet
            daLocalGroceries = New SqlDataAdapter("SELECT * FROM GROCERIES", oCon)
    '*** Define command builder to generate the necessary SQL
            Dim builder As SqlCommandBuilder = New SqlCommandBuilder(daLocalGroceries)
            builder.QuotePrefix = "["
            builder.QuoteSuffix = "]"
    
            Try
                daLocalGroceries.FillSchema(dsSupplies, SchemaType.Source, "LocalGroceries")
                daLocalGroceries.Fill(dsSupplies, "LocalGroceries")
                tblLocalGroceries = dsSupplies.Tables("LocalGroceries")
                dgvLocalGroceries.DataSource = tblLocalGroceries
            Catch ex As Exception
                MsgBox("Something has gone wrong..." & vbNewLine & ex.Message)
    
            End Try
    
        End Sub
    
        Private Sub pbUpdate_Click(sender As System.Object, e As System.EventArgs) Handles pbUpdate.Click
    
            '*** Sub responds to event of button 'update' is clicked. It is intended to reflect
            '*** grid changes back to db
    
            Dim tblChanges As DataTable = tblLocalGroceries.GetChanges()
            Try
                If Not (tblChanges Is Nothing) Then
                    daLocalGroceries.Update(tblChanges)
                End If
            Catch ex As Exception
                MsgBox("Something has gone wrong..." & vbNewLine & ex.Message)
    
            End Try
    
        End Sub 
    End Class
    
    

My Information

Member Title:
D.I.C Regular
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Poland
Full Name:
Bob
Years Programming:
4
Programming Languages:
VB,NET

Contact Information

E-mail:
Click here to e-mail me
ICQ:
ICQ  637172526

Friends

Comments

Page 1 of 1
  1. Photo

    FlashM Icon

    24 Sep 2010 - 14:17
    no problem... you're welcome anytime...
Page 1 of 1