c#


Call CellFormatting when DataGridView is populated


I need to trim the cells in the DataGridView when it's populated with data.
I can't figure out how to call the CellFormatting event from within the DataBindingComplete Event. Surely it's as simple as;
private void iCBOMHDataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
iCBOMHDataGridView_CellFormatting();
}
I am doing something similar that might help. In my case, I am setting an inactive user's whole row to gray text, but it is still cell formatting:
dgvUsers.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvUsers_CellFormatting);
this.Controls.Add(dgvUsers);
The lines above happen before you dgvUsers.Enabled = true; The grid has been loaded, but not displayed. Then the handler that gets called is:
private void dgvUsers_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataRowView row = dgvUsers.Rows[e.RowIndex].DataBoundItem as DataRowView;
if (row != null && row.Row.ItemArray[7].Equals("N"))
{
e.CellStyle.ForeColor = Color.Gray;
dgvUsers.Invalidate();
}
}
The main difference between the cell styling I do and yours is that I am not working with the actual values in the cells, just their styling.

Related Links

How do I determine the sender of an email via Exchange Web Services in C#?
c# fast sort and retrieve for small amount of key value pairs
MySQL Connector - removes polish characters
Project to create a book search website [closed]
C# visual control for editing statements / equations / conditions?
Generate new menus at timed intervals
Mongodb, linq driver. How to construct Contains with variable or statements
How do I retrieve a data type of tinyint from MySQL in C#?
DataTable Join using LINQ in C#
Second Unit Test Not Running
How do i use labels that are in Form1 dsigner at the new class?
LINQ to XML Not Working
c# Deserializing an element based on it's parent node's name
Using MemoryBarrier for Propagation of Changes in Dictionary<int, T> Multithreaded App
How do I know the server got closed with UDP using sockets
Extracting digits from a string five at a time in C#

Categories

HOME
salesforce
cors
latex
xss
sdk
yuv
foreach
symfony-3.2
annyang
http-status-codes
watson-dialog
element
derby
infopath
loss
orange
ejb-3.1
vala
v4l2
mongoose-im
adobe-captivate
request-uri
delphi-2010
storefront
machine-code
aweber
jibx
armadillo
cowboy
icu
aura-framework
ape-phylo
web-technologies
emacs24
enet
playframework-2.3
photoshop-script
programming-pearls
try-catch-finally
suitesparse
fileopendialog
android-tabs
firebase-polymer
racket-student-languages
disconnect
hoare-logic
nimbus
bytearray
paypal-subscriptions
web-optimization
android-progressbar
trendline
methodology
instabug
github-for-mac
consul-template
azure-mobile-app
eaaccessory
dcg
firewire
autopep8
douglas-peucker
backtrace
jsonschema2pojo
unityvs
apache-pivot
api-eveonline
powershell-v1.0
scjp
enquire.js
image-preloader
new-operator
windows-phone-store
netbeans-plugins
mysql-error-1146
mencoder
infomaker
outlook-object-model
mysql2
microsoft-speech-platform
vline
tasklist
php-gettext
ios6-maps
nude.js
stl-algorithm
rjs
pex-and-moles
zipstream
lgpl
xslt-grouping
linq-to-mysql
qprocess
dojox.gfx
content-delivery-network
expander
disk-based

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App