Click here to Skip to main content
15,892,161 members
Home / Discussions / Windows Forms
   

Windows Forms

 
QuestionProblem in ToolStripButton (.Net 2008, Framework 3.5). Pin
priyamtheone12-Nov-10 2:38
priyamtheone12-Nov-10 2:38 
AnswerRe: Problem in ToolStripButton (.Net 2008, Framework 3.5). Pin
musefan12-Nov-10 6:35
musefan12-Nov-10 6:35 
GeneralRe: Problem in ToolStripButton (.Net 2008, Framework 3.5). Pin
priyamtheone13-Nov-10 3:47
priyamtheone13-Nov-10 3:47 
GeneralRe: Problem in ToolStripButton (.Net 2008, Framework 3.5). Pin
musefan15-Nov-10 2:17
musefan15-Nov-10 2:17 
GeneralRe: Problem in ToolStripButton (.Net 2008, Framework 3.5). Pin
priyamtheone16-Nov-10 3:30
priyamtheone16-Nov-10 3:30 
GeneralRe: Problem in ToolStripButton (.Net 2008, Framework 3.5). Pin
musefan16-Nov-10 3:44
musefan16-Nov-10 3:44 
GeneralRe: Problem in ToolStripButton (.Net 2008, Framework 3.5). Pin
priyamtheone16-Nov-10 4:15
priyamtheone16-Nov-10 4:15 
GeneralRe: Problem in ToolStripButton (.Net 2008, Framework 3.5). Pin
priyamtheone18-Nov-10 2:41
priyamtheone18-Nov-10 2:41 
No way, I'm still in darkness. Here's my entire code. please check where's my mistake.

Private strSql As String
    Private da As SqlDataAdapter
    Private bs As BindingSource
    Private dtbl As DataTable

    Private Sub PopulateDgv(Optional ByVal strQuery As String = Nothing)
        Dim bs As BindingSource
        Dim cb As SqlCommandBuilder

        Try
            RoomPriceID = New DataGridViewTextBoxColumn
            PeriodDate = New DataGridViewTextBoxColumn
            Day = New DataGridViewTextBoxColumn
            Cost = New DataGridViewTextBoxColumn
            Price = New DataGridViewTextBoxColumn
            Allotment = New DataGridViewTextBoxColumn
            Notes = New DataGridViewTextBoxColumn

            dgvPriceList.Columns.Clear()
            dgvPriceList.DataSource = Nothing
            dgvPriceList.Columns.AddRange(New DataGridViewColumn() {RoomPriceID, PeriodDate, Day, Cost, Price, Allotment, Notes})

            RoomPriceID.Name = "RoomPriceID"
            RoomPriceID.DataPropertyName = "RoomPriceID"
            RoomPriceID.Visible = False
            PeriodDate.Name = "PeriodDate"
            PeriodDate.DataPropertyName = "PeriodDate"
            PeriodDate.ReadOnly = True
            PeriodDate.HeaderText = "Date"
            PeriodDate.Width = 100
            Day.Name = "Day"
            Day.DataPropertyName = "Day"
            Day.ReadOnly = True
            Day.HeaderText = "Day"
            Day.Width = 100
            Cost.Name = "Cost"
            Cost.DataPropertyName = "Cost"
            Cost.HeaderText = "Cost"
            Cost.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
            Cost.CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleRight
            Cost.Width = 100
            Price.Name = "Price"
            Price.DataPropertyName = "Price"
            Price.HeaderText = "Price"
            Price.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
            Price.CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleRight
            Price.Width = 100
            Allotment.Name = "Allotment"
            Allotment.DataPropertyName = "Allotment"
            Allotment.HeaderText = "Allotment"
            Allotment.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
            Allotment.CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleRight
            Allotment.Width = 100
            Notes.Name = "Notes"
            Notes.DataPropertyName = "Notes"
            Notes.HeaderText = "Notes"
            Notes.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
            Notes.MaxInputLength = 250

            If Not strQuery Is Nothing Then
                bs = New BindingSource
                If dtbl Is Nothing Then dtbl = New DataTable
                da = CreateDataAdapter(strQuery)
                cb = New SqlCommandBuilder(da)
                dtbl.Locale = System.Globalization.CultureInfo.InvariantCulture
                dtbl.Clear()
                da.Fill(dtbl)
                bs.DataSource = dtbl
                dgvPriceList.DataSource = bs
            End If
        Catch ex As Exception
            MsgBox("Error.", MsgBoxStyle.Critical, "Error")
        End Try
    End Sub

    Private Sub frmRoomPriceList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        strSql = "SELECT [RoomPriceID],Convert(nvarchar(10),[PeriodDate],103) As PeriodDate," & _
        "Convert(nvarchar(15), DATENAME(weekday,[PeriodDate])) As [Day],[Cost],[Price],[Allotment],[Notes] " & _
        "FROM [tblRoomPriceDetails] Where RoomPeriodID = " & Me.cboSrchPeriod.SelectedValue
        PopulateDgv(strSql)
        strSql = Nothing
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If dgvPriceList.RowCount > 0 Then
            da.Update(dtbl)
            dtbl.Clear()
            da.Fill(dtbl)
        End If
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        dgvPriceList.EndEdit()
        If dgvPriceList.RowCount > 0 Then
            da.Update(dtbl)
            dtbl.Clear()
            da.Fill(dtbl)
        End If
    End Sub


Only when I edit a cell, go to another cell or row and then press toolstripbutton, the dgv is getting updated and saved. But I want it to happen as soon as I click the toolstripbutton.
GeneralRe: Problem in ToolStripButton (.Net 2008, Framework 3.5). Pin
fnoppers21-Nov-10 16:27
fnoppers21-Nov-10 16:27 
Questionis it possible to show an excel in the window form? Pin
neodeaths31-Oct-10 3:08
neodeaths31-Oct-10 3:08 
AnswerRe: is it possible to show an excel in the window form? Pin
Karthik. A31-Oct-10 5:26
Karthik. A31-Oct-10 5:26 
AnswerRe: is it possible to show an excel in the window form? Pin
RaviRanjanKr18-Dec-10 20:56
professionalRaviRanjanKr18-Dec-10 20:56 
Questiondeveloping webservice for windows form Pin
parul@12318-Oct-10 1:36
parul@12318-Oct-10 1:36 
AnswerRe: developing webservice for windows form PinPopular
Dave Kreskowiak19-Oct-10 2:07
mveDave Kreskowiak19-Oct-10 2:07 
AnswerRe: developing webservice for windows form Pin
Dr.Walt Fair, PE3-Nov-10 5:48
professionalDr.Walt Fair, PE3-Nov-10 5:48 
QuestionA quick Excel Question Pin
Alan Burkhart14-Oct-10 3:48
Alan Burkhart14-Oct-10 3:48 
AnswerRe: A quick Excel Question Pin
DaveAuld18-Oct-10 19:34
professionalDaveAuld18-Oct-10 19:34 
GeneralRe: A quick Excel Question Pin
Alan Burkhart19-Oct-10 3:53
Alan Burkhart19-Oct-10 3:53 
AnswerRe: A quick Excel Question Pin
Ray Cassick19-Dec-10 4:56
Ray Cassick19-Dec-10 4:56 
GeneralRe: A quick Excel Question Pin
Alan Burkhart19-Dec-10 5:16
Alan Burkhart19-Dec-10 5:16 
QuestionRun Code/Fire Event After First Event Finishes Pin
Stinebaugh6-Oct-10 1:34
Stinebaugh6-Oct-10 1:34 
AnswerRe: Run Code/Fire Event After First Event Finishes Pin
Luc Pattyn6-Oct-10 3:37
sitebuilderLuc Pattyn6-Oct-10 3:37 
GeneralRe: Run Code/Fire Event After First Event Finishes Pin
Stinebaugh6-Oct-10 4:37
Stinebaugh6-Oct-10 4:37 
GeneralRe: Run Code/Fire Event After First Event Finishes Pin
Luc Pattyn6-Oct-10 4:42
sitebuilderLuc Pattyn6-Oct-10 4:42 
GeneralRe: Run Code/Fire Event After First Event Finishes Pin
Eddy Vluggen6-Oct-10 7:54
professionalEddy Vluggen6-Oct-10 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.