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

Remove white space from xml node not to attribute value
Unable to cast CheckBoxList.Items to a ListItem - Type or namespace could not be found
Web API - Deserializing body based on URL segment - Model Binder or Media Formatter?
MVC - Abstracting a conversion from an entity (or model) to a ViewModel
How to give your WPF application a flat (Windows 8) type of UI look?
How to generate Entity Framework 6.x POCO classes with mappings from an EDMX file?
lambda innerjoin convert error
Matrix Multiplication with threads
Send XML file on request
Load a function after the layout is being added and shown completely
Updating the key object in AddOrUpdate method
ObjectDisposedException while using socket
How can I add a text box dynamically under an other by pressing a button in c#? (winforms)
VS2013 Dynamically create chart c#
.UpdateLayout() throwns an exception from RunWorkerCompleted method
Unix to Dos Conversion in C#

Categories

HOME
c#
ckan
fortran
snappy
gaussian
azure-resource-manager
flowtype
rethinkdb
oms
core-data
kairosdb
suitecrm
osrm
resharper
popup
dat.gui
taxonomy
css-float
internet-explorer-7
ringcentral
scotty
caldav
android-wifi
wai-aria
functional-dependencies
custom-fields
vtd-xml
edsdk
foxpro
wordpress-rest-api
visual-prolog
luhn
microstrategy
matlab-compiler
android-geofence
pymunk
dotnetnuke-module
linkurious
google-chrome-console
android-graphview
python-venv
gradlew
taleo
line-endings
activeandroid
flask-socketio
gige-sdk
intermediate-language
aws-rds
robotc
scanf
directinput
consolidation
strtol
jspx
init
angularfire
diameter-protocol
jmap
skbio
nslocalizedstring
ewam
clear
android-contentresolver
skscene
webservices-client
php-gd
lytro
autoscaling
avrcp
tooltwist
sparkcore
vensim
eggplant
jeet-grid
beagleboard
numerical-recipes
optimistic-locking
shunting-yard
alpha-beta-pruning
dojox.grid
uiblureffect
qf-test
dirname
redmine-plugins
dotcmis
ccmenuitem
episerver-7
autofilter
octokit
cab
ia-32
pyxplot
servicemanager
database-restore
django-tinymce
invalidoperationexception
django-1.4
cinder
mdd
bootstrap-protocol
expander
memory-consumption

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