We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataGrid sort retrieving SelectedIndex

Thread ID:

Created:

Updated:

Platform:

Replies:

13001 Apr 17,2004 01:03 PM UTC Jun 22,2004 06:50 AM UTC Windows Forms 1
loading
Tags: FAQ
Lucas Heezen
Asked On April 17, 2004 01:03 PM UTC

Hi, Im having this piece of code, but when i sort my datagrid the SelectedIndex seems not to be right anymore. I found here some code but i dont know where to place this code. [code] 'Declare variabelen Dim ds As New DataSet Dim dt As New DataTable Dim columnFullName, columnAdres, columnPostcode, columnStraat As DataColumn Dim row As DataRow Function fillList() 'connect to outlook ' Create Outlook application. Dim oApp As Outlook.Application = New Outlook.Application ' Get namespace and Contacts folder reference. Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI") Dim cContacts As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts) Dim oCount = cContacts.Items.Count Dim contact dt.TableName = "contactPersonen" 'Column FullName columnFullName = New DataColumn columnFullName.DataType = System.Type.GetType("System.String") columnFullName.ColumnName = "Naam" columnFullName.Caption = "Naam" dt.Columns.Add(columnFullName) 'Column Adres columnAdres = New DataColumn columnAdres.DataType = System.Type.GetType("System.String") columnAdres.ColumnName = "Adres" columnAdres.Caption = "Adres" dt.Columns.Add(columnAdres) 'Columns Postcode columnPostcode = New DataColumn columnPostcode.DataType = System.Type.GetType("System.String") columnPostcode.ColumnName = "Postcode" columnPostcode.Caption = "Postcode" dt.Columns.Add(columnPostcode) 'Columns Plaats columnStraat = New DataColumn columnStraat.DataType = System.Type.GetType("System.String") columnStraat.ColumnName = "Plaats" columnStraat.Caption = "Plaats" dt.Columns.Add(columnStraat) 'Place all the items in the listbox. For Each contact In cContacts.Items row = dt.NewRow row.Item("Naam") = contact.FullName row.Item("Adres") = contact.BusinessAddressStreet row.Item("Postcode") = contact.BusinessAddressPostalCode row.Item("Plaats") = contact.BusinessAddressCity dt.Rows.Add(row) Next DataGrid1.DataSource = dt DataGrid1.AllowSorting = True 'Data can be ordered by name DataGrid1.PreferredColumnWidth = 308 'Standaard breedte van de columns DataGrid1.SetDataBinding(dt, "") 'Datagrid laten vullen 'Clear all oApp = Nothing oNS = Nothing cContacts = Nothing contact = Nothing End Function 'Function to fill the datagrid [/code]

Franck
Replied On June 22, 2004 06:50 AM UTC

Hello, Do you found a solution to your problem. I have the same thing. Thanks for your answer if any Woodstock >Hi, Im having this piece of code, but when i sort my datagrid the SelectedIndex seems not to be right anymore. > >I found here some code but i dont know where to place this code. > >[code] >''Declare variabelen > Dim ds As New DataSet > Dim dt As New DataTable > Dim columnFullName, columnAdres, columnPostcode, columnStraat As DataColumn > > Dim row As DataRow > > Function fillList() > > ''connect to outlook > '' Create Outlook application. > Dim oApp As Outlook.Application = New Outlook.Application > > '' Get namespace and Contacts folder reference. > Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI") > Dim cContacts As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts) > Dim oCount = cContacts.Items.Count > > Dim contact > > dt.TableName = "contactPersonen" > > ''Column FullName > columnFullName = New DataColumn > columnFullName.DataType = System.Type.GetType("System.String") > columnFullName.ColumnName = "Naam" > columnFullName.Caption = "Naam" > dt.Columns.Add(columnFullName) > > ''Column Adres > columnAdres = New DataColumn > columnAdres.DataType = System.Type.GetType("System.String") > columnAdres.ColumnName = "Adres" > columnAdres.Caption = "Adres" > dt.Columns.Add(columnAdres) > > ''Columns Postcode > columnPostcode = New DataColumn > columnPostcode.DataType = System.Type.GetType("System.String") > columnPostcode.ColumnName = "Postcode" > columnPostcode.Caption = "Postcode" > dt.Columns.Add(columnPostcode) > > ''Columns Plaats > columnStraat = New DataColumn > columnStraat.DataType = System.Type.GetType("System.String") > columnStraat.ColumnName = "Plaats" > columnStraat.Caption = "Plaats" > dt.Columns.Add(columnStraat) > > ''Place all the items in the listbox. > For Each contact In cContacts.Items > > row = dt.NewRow > row.Item("Naam") = contact.FullName > row.Item("Adres") = contact.BusinessAddressStreet > row.Item("Postcode") = contact.BusinessAddressPostalCode > row.Item("Plaats") = contact.BusinessAddressCity > dt.Rows.Add(row) > > Next > > DataGrid1.DataSource = dt > DataGrid1.AllowSorting = True ''Data can be ordered by name > DataGrid1.PreferredColumnWidth = 308 ''Standaard breedte van de columns > DataGrid1.SetDataBinding(dt, "") ''Datagrid laten vullen > > ''Clear all > oApp = Nothing > oNS = Nothing > cContacts = Nothing > contact = Nothing > > End Function ''Function to fill the datagrid >[/code]

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;