|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrid, binded columns and unbinded columnsI need to know weather it is possible to add a column to a datagrig that based on a dataset, which is not in the dataset (like a description of a code that appear in the datagrid). here is the code I use to present data in the datagrid: Code: Private Sub FillDataGrid(ByRef dsDataSet As DataSet) Try Dim tsTableStyle As New DataGridTableStyle tsTableStyle.MappingName = "myTable" Dim clLineNo As New DataGridTextBoxColumn With clLineNo .MappingName = "line_no" .HeaderText = "Line No" .Width = 50 .NullText = "" End With tsTableStyle.GridColumnStyles.Add(clLineNo) Dim clId As New DataGridTextBoxColumn With clId .MappingName = "id" .HeaderText = "ID" .Width = 80 .NullText = "" End With tsTableStyle.GridColumnStyles.Add(clId) ' Here I want a column that is not mapped to any field in the dataset, but a descrition of the ID which I'll get by calling a function in my DB and here the code I used with custom datagridtextboxcolumn: (between the asterix) '*************************************************************************************************** Dim clDesc As New DataGridTextDescriptionColumn With clDesc '.MappingName = "" '.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, clid.ToString) .HeaderText = "Desc" '.NullText = "" End With tsTableStyle.GridColumnStyles.Add(clDesc) '**************************************************************************************************** Me.dgDataGrid.TableStyles.Clear() Me.dgDataGrid.TableStyles.Add(tsTableStyle) dgDataGrid.SetDataBinding(dsDataSet, "myTable") Catch ex As Exception HandleExceptions(ex) End Try End Sub As a result of this, I wnat to see my grid like this: Line No ID Description 1 S-10 descrition of ID S-10 2 S-20 descrition of ID S-20 and so on... I tryed to use a custom datagridtextboxcolumn (here is the code) Code: Public Class DataGridTextDescriptionColumn Inherits DataGridTextBoxColumn Public Const strConnection = ("Provider=MSDAORA.1;Password=password;User ID=user;Data Source=myDB") Public clsDBORA As New clsDBORA Public Sub New() ' Initialise the object and set its default properities MyBase.New() Me.NullText = "" Me.ReadOnly = True Me.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, "USD") End Sub End Class The result is that I don't see the new column at the grid. If I open the remark from the mappingname property, and map this column to a column in the dataset, I can see the new column, but the data I see is from the mapped field, and not the one I made in my custom control. Do you know what do I miss here? Thanks Thanks Ohad,
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q787q Kerry Moorman Show quoteHide quote "Ohad Weiss" wrote: > Hi all > > I need to know weather it is possible to add a column to a datagrig that > based on a dataset, which is not in the dataset (like a description of a > code that appear in the datagrid). > > here is the code I use to present data in the datagrid: > > Code: > > Private Sub FillDataGrid(ByRef dsDataSet As DataSet) > Try > Dim tsTableStyle As New DataGridTableStyle > tsTableStyle.MappingName = "myTable" > Dim clLineNo As New DataGridTextBoxColumn > With clLineNo > .MappingName = "line_no" > .HeaderText = "Line No" > .Width = 50 > .NullText = "" > End With > tsTableStyle.GridColumnStyles.Add(clLineNo) > Dim clId As New DataGridTextBoxColumn > With clId > .MappingName = "id" > .HeaderText = "ID" > .Width = 80 > .NullText = "" > End With > tsTableStyle.GridColumnStyles.Add(clId) > ' Here I want a column that is not mapped to any field in the dataset, but a > descrition of the ID which I'll get by calling a function in my DB and here > the code I used with custom datagridtextboxcolumn: (between the asterix) > '*************************************************************************************************** > Dim clDesc As New DataGridTextDescriptionColumn > With clDesc > '.MappingName = "" > '.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, > clid.ToString) > .HeaderText = "Desc" > '.NullText = "" > End With > tsTableStyle.GridColumnStyles.Add(clDesc) > '**************************************************************************************************** > Me.dgDataGrid.TableStyles.Clear() > Me.dgDataGrid.TableStyles.Add(tsTableStyle) > dgDataGrid.SetDataBinding(dsDataSet, "myTable") > Catch ex As Exception > HandleExceptions(ex) > End Try > End Sub > > > As a result of this, I wnat to see my grid like this: > Line No ID Description > 1 S-10 descrition of ID S-10 > 2 S-20 descrition of ID S-20 > and so on... > > I tryed to use a custom datagridtextboxcolumn (here is the code) > Code: > > Public Class DataGridTextDescriptionColumn > Inherits DataGridTextBoxColumn > > Public Const strConnection = ("Provider=MSDAORA.1;Password=password;User > ID=user;Data Source=myDB") > Public clsDBORA As New clsDBORA > > Public Sub New() > ' Initialise the object and set its default properities > MyBase.New() > Me.NullText = "" > Me.ReadOnly = True > Me.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, "USD") > End Sub > End Class > > The result is that I don't see the new column at the grid. > If I open the remark from the mappingname property, and map this column to a > column in the dataset, I can see the new column, but the data I see is from > the mapped field, and not the one I made in my custom control. > > Do you know what do I miss here? > > Thanks > > Thanks > > > It is in c
Do you know about doing it in vb? Ohad Show quoteHide quote "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message news:2F31A514-ADEB-448F-9C9D-F5B48D6EEA95@microsoft.com... > Ohad, > > http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q787q > > Kerry Moorman > > > "Ohad Weiss" wrote: > >> Hi all >> >> I need to know weather it is possible to add a column to a datagrig that >> based on a dataset, which is not in the dataset (like a description of a >> code that appear in the datagrid). >> >> here is the code I use to present data in the datagrid: >> >> Code: >> >> Private Sub FillDataGrid(ByRef dsDataSet As DataSet) >> Try >> Dim tsTableStyle As New DataGridTableStyle >> tsTableStyle.MappingName = "myTable" >> Dim clLineNo As New DataGridTextBoxColumn >> With clLineNo >> .MappingName = "line_no" >> .HeaderText = "Line No" >> .Width = 50 >> .NullText = "" >> End With >> tsTableStyle.GridColumnStyles.Add(clLineNo) >> Dim clId As New DataGridTextBoxColumn >> With clId >> .MappingName = "id" >> .HeaderText = "ID" >> .Width = 80 >> .NullText = "" >> End With >> tsTableStyle.GridColumnStyles.Add(clId) >> ' Here I want a column that is not mapped to any field in the dataset, >> but a >> descrition of the ID which I'll get by calling a function in my DB and >> here >> the code I used with custom datagridtextboxcolumn: (between the asterix) >> '*************************************************************************************************** >> Dim clDesc As New DataGridTextDescriptionColumn >> With clDesc >> '.MappingName = "" >> '.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, >> clid.ToString) >> .HeaderText = "Desc" >> '.NullText = "" >> End With >> tsTableStyle.GridColumnStyles.Add(clDesc) >> '**************************************************************************************************** >> Me.dgDataGrid.TableStyles.Clear() >> Me.dgDataGrid.TableStyles.Add(tsTableStyle) >> dgDataGrid.SetDataBinding(dsDataSet, "myTable") >> Catch ex As Exception >> HandleExceptions(ex) >> End Try >> End Sub >> >> >> As a result of this, I wnat to see my grid like this: >> Line No ID Description >> 1 S-10 descrition of ID S-10 >> 2 S-20 descrition of ID S-20 >> and so on... >> >> I tryed to use a custom datagridtextboxcolumn (here is the code) >> Code: >> >> Public Class DataGridTextDescriptionColumn >> Inherits DataGridTextBoxColumn >> >> Public Const strConnection = >> ("Provider=MSDAORA.1;Password=password;User >> ID=user;Data Source=myDB") >> Public clsDBORA As New clsDBORA >> >> Public Sub New() >> ' Initialise the object and set its default properities >> MyBase.New() >> Me.NullText = "" >> Me.ReadOnly = True >> Me.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, >> "USD") >> End Sub >> End Class >> >> The result is that I don't see the new column at the grid. >> If I open the remark from the mappingname property, and map this column >> to a >> column in the dataset, I can see the new column, but the data I see is >> from >> the mapped field, and not the one I made in my custom control. >> >> Do you know what do I miss here? >> >> Thanks >> >> Thanks >> >> >> I don't think you can do this the way you are trying to do it. The problem
lies in the fact that the column you're trying to add is a structure but you're trying to push data into it as if they were rows or records. You might want to consider adding the Description as part of your query (part of DataSet) instead of the painstaking way you're trying to add the data here. Show quoteHide quote "Ohad Weiss" <oh***@netvision.net.il> wrote in message news:44512020@news.bezeqint.net... > Hi all > > I need to know weather it is possible to add a column to a datagrig that > based on a dataset, which is not in the dataset (like a description of a > code that appear in the datagrid). > > here is the code I use to present data in the datagrid: > > Code: > > Private Sub FillDataGrid(ByRef dsDataSet As DataSet) > Try > Dim tsTableStyle As New DataGridTableStyle > tsTableStyle.MappingName = "myTable" > Dim clLineNo As New DataGridTextBoxColumn > With clLineNo > .MappingName = "line_no" > .HeaderText = "Line No" > .Width = 50 > .NullText = "" > End With > tsTableStyle.GridColumnStyles.Add(clLineNo) > Dim clId As New DataGridTextBoxColumn > With clId > .MappingName = "id" > .HeaderText = "ID" > .Width = 80 > .NullText = "" > End With > tsTableStyle.GridColumnStyles.Add(clId) > ' Here I want a column that is not mapped to any field in the dataset, but > a descrition of the ID which I'll get by calling a function in my DB and > here the code I used with custom datagridtextboxcolumn: (between the > asterix) > '*************************************************************************************************** > Dim clDesc As New DataGridTextDescriptionColumn > With clDesc > '.MappingName = "" > '.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, > clid.ToString) > .HeaderText = "Desc" > '.NullText = "" > End With > tsTableStyle.GridColumnStyles.Add(clDesc) > '**************************************************************************************************** > Me.dgDataGrid.TableStyles.Clear() > Me.dgDataGrid.TableStyles.Add(tsTableStyle) > dgDataGrid.SetDataBinding(dsDataSet, "myTable") > Catch ex As Exception > HandleExceptions(ex) > End Try > End Sub > > > As a result of this, I wnat to see my grid like this: > Line No ID Description > 1 S-10 descrition of ID S-10 > 2 S-20 descrition of ID S-20 > and so on... > > I tryed to use a custom datagridtextboxcolumn (here is the code) > Code: > > Public Class DataGridTextDescriptionColumn > Inherits DataGridTextBoxColumn > > Public Const strConnection = > ("Provider=MSDAORA.1;Password=password;User ID=user;Data Source=myDB") > Public clsDBORA As New clsDBORA > > Public Sub New() > ' Initialise the object and set its default properities > MyBase.New() > Me.NullText = "" > Me.ReadOnly = True > Me.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, "USD") > End Sub > End Class > > The result is that I don't see the new column at the grid. > If I open the remark from the mappingname property, and map this column to > a column in the dataset, I can see the new column, but the data I see is > from the mapped field, and not the one I made in my custom control. > > Do you know what do I miss here? > > Thanks > > Thanks > > Ohad,
It is so simple that this is two samples in one on our website. http://www.windowsformsdatagridhelp.com/default.aspx?ID=76a81eb8-ea2d-48f4-99c3-a3539697edbd You don't need the mapping part because you use styles I hope ths helps, Cor
DLL does not load Dynamically
Stepping between .Net IDE into a VB6 dll call simple combo question ImageList - Memory-Issue in vs2005 is this possible... Format Function Redirect question WMI - Executing a method to read registry - Going Crazy! FileSystemWatcher any experts here? General Design Question - Class Name |
|||||||||||||||||||||||