c# - How to custom format data in datagridview during databinding -


I'm looking at a way to format DataGridViewTextBoxColumn so that the value of the data bonded formatted during the database. For example, I have the property of the company name and I need to take 5 characters before the database name.

I can hook and hook the loop through various datagrid view events (like added in rows) and all the rows, but I want to find more sophisticated ways to do this . Since I have decided to use the database, looping through data and modifying it have little against the databasing concept.

What I'm doing after this, as follows, but add custom formatting logic:

  DataGride View 1 Column [colsoddate. Index] .DataPropertyName = "SomeDate"; ColSomeDate.DefaultCellStyle.Format = "yyyy";  

I think I should implement the IFormatProvider, but I do not understand how I should implement it.

  dataGridView1.Column [companyName.Index]. DataPropertyName = "CompanyName"; CompanyName.DefaultCellStyle.FormatProvider = New Shorttext (); // ShortText should apply to IFormatProvider  

I do not know about the IFormatProvider, But Can DataGridViews Help With CellFormatting-Event?

  Private zero dataGridView1_CellFormatting (Object Sender, DataGridViewCellFormattingEventArgsE) {if (e.ColumnIndex == 0) {e.Value = e.Value.ToString () substrings (0, 5). // apply formating here e.formattingApplied = true; }}  


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -