Prev: haftpflichtversicherung, hausratversicherung definition, hausrat wertsachen, hausratversicherungen vergleichen, hausratversicherung monatlich,
Next: snk
From: Andy O'Neill on 15 Feb 2010 16:17 "Kali" <noemail(a)address.com> wrote in message news:uM05penrKHA.1796(a)TK2MSFTNGP02.phx.gbl... > Thanks Andy. I see where you're defining the columns and adding the > items, etc. but I don't see where you're selecting existing records and > allowing the user to edit. Am I looking at this the wrong way? You don't see it because you don't need any. Bear in mind that code is from a working commercial application. You don't write code to select the existing records except to alter that select sql. You need to read up on binding mate. Datasets are writable. Bind to one and you need absoltuely zero code to write back to it from a windows datagrid(view).. You do, however. have to write the insert, delete and update sql that goes into the dataadapter.
From: Kali on 15 Feb 2010 16:25 Thank you Andy. I very much appreciate the feedback. I think I'm just confused between the complexity of an asp.net app and the ease of a windows app (as it pertains to the datagrid anyways). So do I define the columns in the properties (colomns collection) first. Then populate the data from a sql statement? is the datagrid(view) always aware of the underlying adatper/dataset that bound it? Will the value of the drop down list auto select based on the select statement to get the existing data? Eg. will Book 2 auto select in the combobox if it's bound to a dataset? "Andy O'Neill" <aon14nocannedmeat(a)lycos.co.uk> wrote in message news:hRien.46878$zD4.9292(a)newsfe19.ams2... > > "Kali" <noemail(a)address.com> wrote in message > news:uM05penrKHA.1796(a)TK2MSFTNGP02.phx.gbl... >> Thanks Andy. I see where you're defining the columns and adding the >> items, etc. but I don't see where you're selecting existing records and >> allowing the user to edit. Am I looking at this the wrong way? > > You don't see it because you don't need any. > Bear in mind that code is from a working commercial application. > > You don't write code to select the existing records except to alter that > select sql. > You need to read up on binding mate. > > Datasets are writable. > Bind to one and you need absoltuely zero code to write back to it from a > windows datagrid(view).. > You do, however. have to write the insert, delete and update sql that goes > into the dataadapter. > >
From: Andy O'Neill on 15 Feb 2010 17:08 "Kali" <noemail(a)address.com> wrote in message news:u3l4wVorKHA.4948(a)TK2MSFTNGP05.phx.gbl... > Thank you Andy. I very much appreciate the feedback. I think I'm just > confused between the complexity of an asp.net app and the ease of a > windows app (as it pertains to the datagrid anyways). The asp.net app was badly written mate. Somewhere out there on the web will be introductory articles on how to work with strongly typed datasets, binding and windows forms. I would advise you to find and read them then go back and look at my code. There is no way I can write as clear and extensive an explanation as you need. > > So do I define the columns in the properties (colomns collection) first. > Then populate the data from a sql statement? If you configure it via the collection property then you need to have already bound it. I used to write that template stuff manually. > is the datagrid(view) always aware of the underlying adatper/dataset that > bound it? Read up on binding. >Will the value of the drop down list auto select based on the select >statement to get the existing data? Eg. will Book 2 auto select in the >combobox if it's bound to a dataset? Read my previous post again,
From: Kali on 15 Feb 2010 17:20 Will do, Andy. Thank you very much for the assistance. I really appreciate it. I'd much prefer to add columns programmatically vs. the columns collection. I will read up on strongly typed datasets and binding to the control. I'll then review your posts. Thank you very much. "Andy O'Neill" <aon14nocannedmeat(a)lycos.co.uk> wrote in message news:lBjen.7$3E5.0(a)newsfe18.ams2... > > "Kali" <noemail(a)address.com> wrote in message > news:u3l4wVorKHA.4948(a)TK2MSFTNGP05.phx.gbl... >> Thank you Andy. I very much appreciate the feedback. I think I'm just >> confused between the complexity of an asp.net app and the ease of a >> windows app (as it pertains to the datagrid anyways). > > The asp.net app was badly written mate. > > Somewhere out there on the web will be introductory articles on how to > work with strongly typed datasets, binding and windows forms. > I would advise you to find and read them then go back and look at my code. > There is no way I can write as clear and extensive an explanation as you > need. > >> >> So do I define the columns in the properties (colomns collection) first. >> Then populate the data from a sql statement? > > If you configure it via the collection property then you need to have > already bound it. > I used to write that template stuff manually. > >> is the datagrid(view) always aware of the underlying adatper/dataset that >> bound it? > > Read up on binding. > >>Will the value of the drop down list auto select based on the select >>statement to get the existing data? Eg. will Book 2 auto select in the >>combobox if it's bound to a dataset? > > Read my previous post again, > >
From: Kali on 15 Feb 2010 18:23
Hi Andy. Line... Dim cboReg As New DataGridBoundComboColumn doesn't seem to work in VStudio 2008. VStudio doesn't understand DataGridBoundComboColumn. Any ideas? "Andy O'Neill" <aon14nocannedmeat(a)lycos.co.uk> wrote in message news:lTeen.108591$5n1.94157(a)newsfe01.ams2... > > "Kali" <noemail(a)address.com> wrote in message > news:Ok9NOvkrKHA.5896(a)TK2MSFTNGP04.phx.gbl... >> Thank you, Andy. Will take a look at the article. Some of the issues >> I'm having are the event handlers compared to asp.net... onitemdatabound, >> etc. I am able to add a combobox to a datagridview and populate its >> listitems, however, I'm not able to keep that combobox when binding the >> data from an existing set of data. > > The way binding works in windows forms is different now, I think. > What I used to do is apply a style to the table. > I can't recall why, but there was an advantage to doing this in code > rather than the column collection. > > Here's some old code which has a combo box in it. > ======= > Dim ts1 As New DataGridTableStyle() > > ts1.MappingName = "Salesmen" > > ts1.AlternatingBackColor = Color.LightBlue > > Dim TextCol_0 As New DataGridTextBoxColumn() > > TextCol_0.MappingName = "Salesman_Id" > > TextCol_0.HeaderText = "Salesman Id" > > TextCol_0.Width = 70 > > TextCol_0.TextBox.MaxLength = 8 > > ts1.GridColumnStyles.Add(TextCol_0) > > '========= > > Dim cboReg As New DataGridBoundComboColumn > > cboReg.MappingName = "Region_Id" > > cboReg.HeaderText = "Region" > > cboReg.Width = 120 > > Try > > Dim sconn As String = Conn_String() > > Dim conn As SqlConnection = New SqlConnection(sconn) > > Dim SqlString As String = "select null as region_id, '(Null)' as Region " > & _ > > "Union " & _ > > "Select Region_id, Region from Regions " & _ > > "order by Region" > > Dim daRg = New SqlDataAdapter(SqlString, conn) > > Dim dsRg = New DataSet > > daRg.Fill(dsRg, "Regions") > > With cboReg.ColumnBoundComboBox > > .DataSource = dsRg.Tables("Regions").DefaultView > > .DisplayMember = "Region" > > .ValueMember = "Region_id" > > End With > > Catch ex As SqlException > > MsgBox("Error reading Regions " & ex.Number & " " & ex.Message()) > > End Try > > ts1.PreferredRowHeight = cboReg.ColumnBoundComboBox.Height + 3 > > ts1.GridColumnStyles.Add(cboReg) > > '===== > > Dim TextCol_3 As New DataGridTextBoxColumn > > TextCol_3.MappingName = "Salesman_Name" > > TextCol_3.HeaderText = "Salesman Name" > > TextCol_3.Width = 110 > > TextCol_3.TextBox.MaxLength = 30 > > ts1.GridColumnStyles.Add(TextCol_3) > > Dim TextCol_4 As New DataGridBoolColumn > > TextCol_4.MappingName = "Manager" > > TextCol_4.HeaderText = "Manager" > > TextCol_4.Width = 50 > > TextCol_4.AllowNull = False > > TextCol_4.FalseValue = "N" > > TextCol_4.TrueValue = "Y" > > ts1.GridColumnStyles.Add(TextCol_4) > > Me.grdSalesmen.TableStyles.Add(ts1) > |