Click here to Skip to main content
15,914,016 members
Home / Discussions / C#
   

C#

 
AnswerRe: How memory is released for the unmanaged objects Pin
Scott Dorman1-Sep-06 13:17
professionalScott Dorman1-Sep-06 13:17 
GeneralRe: How memory is released for the unmanaged objects Pin
Rickey_Me11-Sep-06 1:26
Rickey_Me11-Sep-06 1:26 
QuestionHow to append the text in listbox or listview ? Pin
Sri harini27-Aug-06 22:09
Sri harini27-Aug-06 22:09 
AnswerRe: How to append the text in listbox or listview ? Pin
X'Nork27-Aug-06 22:22
X'Nork27-Aug-06 22:22 
GeneralRe: How to append the text in listbox or listview ? Pin
Sri harini27-Aug-06 22:49
Sri harini27-Aug-06 22:49 
QuestionSuggestion required Pin
<color>Aljechin 27-Aug-06 22:02
<color>Aljechin 27-Aug-06 22:02 
AnswerRe: Suggestion required Pin
Ed.Poore27-Aug-06 22:03
Ed.Poore27-Aug-06 22:03 
QuestionC# Datagrid painting Pin
Ashish_Sood27-Aug-06 21:48
Ashish_Sood27-Aug-06 21:48 
Hi,

I have a datagrid that is binded to a datatable (in form of a dataview). I have a requirement that when a particular column in the grid has a value (say 'stat'), then the entire row should be painted in red(the text should be red) else black.

I have extended DatagridColumnStyles for my custom columns. In the paint method, i check for the value in the dataview and accordingly set the forebrush.However, when the user sorts the grid, although it shows the dataview to be sorted, still, the value retrieved is incorrect. I use the row parameter of paint to get the value from the dataview.

Here is the sample code

protected override void Paint(Graphics g, Rectangle rect, CurrencyManager cm, int row, Brush backBrush, Brush foreBrush, bool rightAlign)
{
bool isStatRow = false;
DataRowView rView = null;
try
{
DataView dview = DataGridTableStyle.DataGrid.DataSource as DataView;
if( dview != null )
{
string strStat = dview.Table.Rows[row]["ORD_SCHEDULE_INTERVAL"] as string;
if( strStat != null )
{
string val = strStat.Trim().ToLower();
if( val.IndexOf("stat") == -1 )
isStatRow = false;
else
isStatRow=true;
}
}
}
catch(Exception ex)
{
}

g.FillRectangle(backBrush, rect);
string str = HelperClass.GetString(GetColumnValueAtRow(cm, row), NullText);

if( isStatRow )
{
g.DrawString(str, DataGridTableStyle.DataGrid.Font, new SolidBrush(Color.Red), rect);
}
else
{
g.DrawString(str, DataGridTableStyle.DataGrid.Font, foreBrush, rect);
}

}

The code works when the grid is first painted, but once the same is sorted, this returns me errorneous values and thus paints the color wrongly. I tried using currencymanager.Current also but to no use.

Any ideas???

Please respond


Ashish Sood

Questioncheck if user (by sid) is member of group (by sid) Pin
Goerlandt27-Aug-06 21:14
Goerlandt27-Aug-06 21:14 
QuestionListview.SelectedItems Pin
Sri harini27-Aug-06 21:07
Sri harini27-Aug-06 21:07 
AnswerRe: Listview.SelectedItems Pin
Nader Elshehabi28-Aug-06 2:48
Nader Elshehabi28-Aug-06 2:48 
GeneralRe: Listview.SelectedItems Pin
Sri harini28-Aug-06 16:51
Sri harini28-Aug-06 16:51 
GeneralRe: Listview.SelectedItems Pin
Nader Elshehabi28-Aug-06 19:13
Nader Elshehabi28-Aug-06 19:13 
GeneralRe: Listview.SelectedItems Pin
Sri harini28-Aug-06 21:30
Sri harini28-Aug-06 21:30 
AnswerRe: Listview.SelectedItems Pin
Nader Elshehabi29-Aug-06 3:37
Nader Elshehabi29-Aug-06 3:37 
QuestionAdding a file to solution explorer using Add-Ins [modified] Pin
Phanindra Kumar27-Aug-06 20:28
Phanindra Kumar27-Aug-06 20:28 
AnswerRe: Adding a file to solution explorer using Add-Ins Pin
Nader Elshehabi28-Aug-06 2:52
Nader Elshehabi28-Aug-06 2:52 
QuestionMetafile (wmf/emf) manipulation help needed Pin
kunaalmalhotra27-Aug-06 20:02
kunaalmalhotra27-Aug-06 20:02 
QuestionAbout Webpage Setting Pin
Ahmad Zia Quaiser27-Aug-06 19:19
Ahmad Zia Quaiser27-Aug-06 19:19 
AnswerRe: About Webpage Setting Pin
Guffa27-Aug-06 23:24
Guffa27-Aug-06 23:24 
AnswerRe: About Webpage Setting Pin
Nader Elshehabi28-Aug-06 1:25
Nader Elshehabi28-Aug-06 1:25 
QuestionAbout Webpage Setting Pin
Ahmad Zia Quaiser27-Aug-06 19:18
Ahmad Zia Quaiser27-Aug-06 19:18 
AnswerRe: About Webpage Setting Pin
jithen_dt28-Aug-06 1:28
jithen_dt28-Aug-06 1:28 
QuestionA question about maskedTextBox control Pin
mariodai36527-Aug-06 15:17
mariodai36527-Aug-06 15:17 
AnswerRe: A question about maskedTextBox control Pin
Nader Elshehabi27-Aug-06 15:27
Nader Elshehabi27-Aug-06 15:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.