.net - Build DataGridView table without a source? -


I've never worked as much as I needed, but I'm returning it again and hoping I know I can find it, find out. Currently I have a class where I store a lot of data about each individual support ticket coming in every software, but I only want to display some data on the DataGrid view.

The class looks as follows: ..

  public class tickets {get public string ID { Set; } Public String TicketID {get; Set; } Public String DeptID {get; Set; } Public String UserID {get; Set; } Public string name {get; Set; } Public String Email {get; Set; } Public string c {get; Set; } Public string theme {get; Set; } Public string message {get; Set; } Public string status {get; Set; } Public String Priority {Received; Set; } Public Date Time Date {Received; Set; } Public DateTime LastResponse {get; Set; } Public IPadation IP {Receive; Set; }}   

I want to create a table that shows name / message / priority or some combination of these values, but of course all of them are no way Can I just create table data from scratch instead of supplying it to a data source?

Here's my test code to apply the suggestion, but I'm getting "No row can be added in the data grid view control column".

  WHMCS x = new WHMCS (); & Lt; WHMCS.Ticket & gt; Ticket = New list & amp; Lt; WHMCS.Ticket & gt; (); Ticket = x.Get_Tickets (); KryptonDataGridView DGV = New KryptonDataGridView (); Content1.Controls.Add (DGV); Forchach (ticket in tic tick) {var objArr = new object [] {tix.Priority, tix.Subject}; Dgv.Rows.Add (objArr); }    

You manually add rows by converting your ticket class into an object array You can. The fields you are interested in, then add the datagrid. Some kind

  foreach (Varial tickets in the oscillator) {var objArr = new object [] {ticket.Id, ticket.DeptId ...}; DataGrid.Rows.Add (objArr); }   

Be sure that the types of arrays correspond to the types expected by each column, and you will need to manually transmit prices to your data source if they are editable by the user. Are there.

In reply to your comment: Before adding the rows, populate the datagrid with the column:

  _colId = New DataGrid view text code column {name = "id ", Header text = id.filed date, AutoSizeMode = DataGridViewAutoSizeColumnMode.None, width = 150, readonly = true;}; // ... datagrid Column.ed (_colId); DataGrid.Columns.Add (Other Columns ...);   

Use the property that you require at each column.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -