Current filter:
                                You should refresh the page.
                                  • Hi

                                    As per code snippet below I am adding data to your GridControl from a SQLite database

                                    I need to access the columns by name in the FocusedRowChanged event, but despite adding the columns in code and giving them names I cannot see the column names only the data?

                                    [VB.NET]
                                    Public Sub RunQuery() Me.Invoke(Sub() btnRunQuery.Enabled = False) Dim SQLiteConnect = New SQLiteConnection("Data Source=" & SQLiteDatabasePath) Try Using SQLiteConnect SQLiteConnect.OpenAsync() Dim SQLiteCommandText = "SELECT TimeCreated,EventLog,Computer,Source,Level,Id,ShortMessage,TargetUserName,SubjectUserName FROM eventlogarchive WHERE (TargetUserName LIKE '%donna_g%' OR SubjectUserName LIKE '%donna_g%') AND TimeCreated >= '29/08/2017 00:00:00' AND TimeCreated <= '31/08/2017 23:59:59' ORDER BY TimeCreated DESC" Dim cmdDataGrid As SQLiteCommand = New SQLiteCommand(SQLiteCommandText, SQLiteConnect) Dim da As New SQLiteDataAdapter da.SelectCommand = cmdDataGrid Dim dt As New DataTable da.Fill(dt) Me.Invoke(Sub() GridControl1.DataSource = dt) Me.Invoke(Sub() GridView1.BestFitColumns()) ' so columns fit to content Dim readerDataGrid As SQLiteDataReader = cmdDataGrid.ExecuteReader() SQLiteConnect.Close() End Using Private Sub SetupGrid() Dim gcQuery1 As GridColumn = GridView1.Columns.AddField("TimeCreated") gcQuery1.Caption = "Date/Time" gcQuery1.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime gcQuery1.DisplayFormat.FormatString = "dd/MM/yyyy HH:mm:ss" gcQuery1.Width = 120 gcQuery1.MaxWidth = 120 gcQuery1.OptionsColumn.AllowEdit = False gcQuery1.Visible = True Dim gcQuery2 As GridColumn = GridView1.Columns.AddField("Id") gcQuery2.Caption = "Event ID" gcQuery2.Width = 60 gcQuery2.MaxWidth = 60 gcQuery2.OptionsColumn.AllowEdit = False gcQuery2.Visible = True Dim gcQuery3 As GridColumn = GridView1.Columns.AddField("Source") gcQuery3.Caption = "Source" gcQuery3.Width = 190 gcQuery3.MaxWidth = 190 gcQuery3.OptionsColumn.AllowEdit = False gcQuery3.Visible = True Dim gcQuery4 As GridColumn = GridView1.Columns.AddField("Level") gcQuery4.Caption = "Level" gcQuery4.Width = 80 gcQuery4.MaxWidth = 80 gcQuery4.OptionsColumn.AllowEdit = False gcQuery4.Visible = True Dim gcQuery5 As GridColumn = GridView1.Columns.AddField("Computer") gcQuery5.Caption = "Computer" gcQuery5.Width = 120 gcQuery5.MaxWidth = 120 gcQuery5.OptionsColumn.AllowEdit = False gcQuery5.Visible = True Dim gcQuery6 As GridColumn = GridView1.Columns.AddField("ShortMessage") gcQuery6.Caption = "Message" gcQuery6.Width = 120 gcQuery6.OptionsColumn.AllowEdit = False gcQuery6.Visible = True Dim gcQuery7 As GridColumn = GridView1.Columns.AddField("TargetUserName") gcQuery7.Caption = "TargetUserName" gcQuery7.Width = 120 gcQuery7.OptionsColumn.AllowEdit = False gcQuery7.Visible = False End Sub

                                     

                                • Andrew Ser (DevExpress Support) 09.06.2017

                                  Hello Darren,
                                  Do I understand correctly that you want to write similar code in the FocusedRowChanged event handler?
                                  ...GetRowCellValue(rowHandle, gcQuery1)
                                  If so, it is impossible in VB.NET since you declared the gcQuery1 variable in the scope of the SetupGrid method. This variable exists only in this method.
                                  If you want to get a grid column in another method, obtain it from the GridView.Columns collection by its field name:

                                  [VB.NET]
                                  Dim myColumn As GridColumn = GridView.Columns("TimeCreated")

                                  If I misunderstood your task, please describe it in greater detail.

                                • Darren Rose 09.06.2017

                                  Hi Andrew

                                  Thanks for your prompt reply

                                  In a previous project where the datasource of my grid was a collection of items I could use code as below to access column values

                                  But with this project I cannot and I don't understand why

                                  [VB.NET]
                                  Dim gridView As GridView = TryCast(GridControl1.FocusedView, GridView) Dim row As Object = gridView.GetRow(gridView.FocusedRowHandle) If row IsNot Nothing Then lblLoggedDate.Text = Format(row.TimeCreated, "dd/MM/yyyy HH:mm:ss") lblEventID.Text = row.Id lblSource.Text = row.ProviderName End If

                                  So if I typed row. then automatically it would show me column names I could choose from

                                  Basically I need to be able (in the focused row changed event) to be able to access current values from some of the columns

                                  How can I access value of chosen column on currently selected row

                                1 Solution

                                Creation Date Importance Sort by

                                Hi,
                                Thank you for the clarification.
                                VB.NET allows you to write property names even though an object type is not explicitly declared. That is, you were able to type row.Id even though the row variable is of the Object type. It was possible because the GridView.GetRow method returned a record that is of your custom type, say, Person. The Person class had the Id and ProviderName public properties.
                                Now, you are using untyped DataSets and DataTables. Rows of such tables don't expose any public properties and you can access them only by using an indexer (something in the square brackets). You can find more information in the Typed vs. untyped datasets MSDN topic.

                                I hope you find this information useful.

                                • Darren Rose 09.06.2017

                                  Okay thanks, now I understand difference between my other app and this one

                                  So what is best way using your controls for me to achieve what I need then - can you offer an example or post some code?

                                  Basically what I am trying to achieve is this:-

                                  I run a SQL query against my SQLite database and the results are shown in the gridcontrol - only some columns (the important ones) are visible in the gridcontrol

                                  When I click on a row I want to then be able to show in a panel below the contents of some of the "hidden" columns, so basically it will be a summary panel and clicking an item populates this panel

                                  So I need to access the contents of a cell in a specific column and the selected row

                                  If there is a better way for me to do this using any other DevExpress controls then please let me know

                                  Thank you very much

                                • Andrew Ser (DevExpress Support) 09.06.2017

                                  Hi,
                                  Let's discuss this task in a separate ticket I've created on your behalf - Grid - How to show data from hidden columns in a separate panel.