Click here to Skip to main content
15,884,986 members
Home / Discussions / C#
   

C#

 
AnswerRe: get GUID from Assembly Information Pin
Ravi Mori22-Sep-09 21:00
Ravi Mori22-Sep-09 21:00 
AnswerRe: get GUID from Assembly Information Pin
0x3c022-Sep-09 23:42
0x3c022-Sep-09 23:42 
QuestionIBasicVideo2 GetCurrentImage returns black frames Pin
smilefishcc22-Sep-09 20:45
smilefishcc22-Sep-09 20:45 
QuestionTest Cases for the Code Pin
jpk42022-Sep-09 20:36
jpk42022-Sep-09 20:36 
AnswerRe: Test Cases for the Code Pin
Richard MacCutchan22-Sep-09 22:59
mveRichard MacCutchan22-Sep-09 22:59 
AnswerRe: Test Cases for the Code Pin
N a v a n e e t h23-Sep-09 0:18
N a v a n e e t h23-Sep-09 0:18 
QuestionODBC Data Error Pin
sateesh villa22-Sep-09 20:35
sateesh villa22-Sep-09 20:35 
QuestionAccessing Non-Public Members [modified] Pin
John Jak22-Sep-09 20:15
John Jak22-Sep-09 20:15 
I would like to know how can I get access to the Non-Public members of a class. In this case it is the
CellPaintinEventArgs of a DataGridView control that I would like to be able to access outside of the CellPainting event.
I know it's not common practice or even if it's possible, but I would like to call the CellPainting event directly and pass in the DataGrid and CellPaintingEventArgs myself.

Reason being is I am trying to improve the performance (efficiency) of the CellPainting event for the DataGridView control. From a little experimentation, I have discovered that the CellPainting event fires for cells that do not require updating. I am using DataGrids that can take up the entire display of a 19" Wide display and sometimes only a few cells need updating yet depending on the location of those cells, many more cells appear to be repainted unnecessarily. This noticeably slows the updating of the grid. The data is not bound to the grid and no rows or columns are added or removed from the grid. In other words the grid size remains static so there is nothing extreme happening that would force the grid to repaint most of its cells.

The code below illustrates this. Use the default names for the components on the form. Also stretch out the grid so there's no need to scroll. Just click on different cells to change the current selected cell and you will notice that the counter reveals how many times the CellPainting event is fired for something as trivial as this! Click on the first cell and then click on the last cell, the counter increments as many times as there are cells on the grid!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace dgvTester
{
    public partial class Form1 : Form
    {
        private int counter = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.RowCount = 10;
            dataGridView1.ColumnCount = 10;
            for (int column = 0; column < dataGridView1.ColumnCount; column++)
                dataGridView1.Columns[column].Width = 50;
            dataGridView1.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.dataGridView1_CellPainting);
        }

        private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            counter++;
            label1.Text = counter.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            counter = 0;
            label1.Text = counter.ToString();
        }
    }
}

Do I have to override the accessibility of the CellPaintingEventArgs to be able to do this?
I found this link, don't know if it will help or how to use it:
http://www.koders.com/csharp/fid1DBCB1E079D023FE239DE7F27C34FAC67DA643AF.aspx?s=cdef%3Adatagridview#L34

Any help is much appreciated!

john....

modified on Wednesday, September 23, 2009 2:22 AM

QuestionSkins in C# Pin
vivasaayi22-Sep-09 19:11
vivasaayi22-Sep-09 19:11 
AnswerRe: Skins in C# Pin
egenis22-Sep-09 19:25
egenis22-Sep-09 19:25 
GeneralRe: Skins in C# Pin
vivasaayi22-Sep-09 19:52
vivasaayi22-Sep-09 19:52 
GeneralRe: Skins in C# Pin
Ravi Mori22-Sep-09 20:00
Ravi Mori22-Sep-09 20:00 
GeneralRe: Skins in C# Pin
vivasaayi22-Sep-09 20:33
vivasaayi22-Sep-09 20:33 
GeneralRe: Skins in C# Pin
egenis22-Sep-09 20:36
egenis22-Sep-09 20:36 
QuestionNeed help with updating SQL server express DB from c# Pin
Mark-12345678922-Sep-09 16:15
Mark-12345678922-Sep-09 16:15 
Answerrepost Pin
Luc Pattyn22-Sep-09 16:29
sitebuilderLuc Pattyn22-Sep-09 16:29 
AnswerRe: Need help with updating SQL server express DB from c# Pin
Michael Eber22-Sep-09 18:53
Michael Eber22-Sep-09 18:53 
GeneralRe: Need help with updating SQL server express DB from c# Pin
Mark-12345678923-Sep-09 2:43
Mark-12345678923-Sep-09 2:43 
GeneralRe: Need help with updating SQL server express DB from c# Pin
PIEBALDconsult23-Sep-09 5:12
mvePIEBALDconsult23-Sep-09 5:12 
GeneralRe: Need help with updating SQL server express DB from c# - Done IT! Pin
Mark-12345678924-Sep-09 9:02
Mark-12345678924-Sep-09 9:02 
GeneralRe: Need help with updating SQL server express DB from c# - Done IT! Pin
PIEBALDconsult24-Sep-09 9:23
mvePIEBALDconsult24-Sep-09 9:23 
GeneralRe: Need help with updating SQL server express DB from c# - Done IT! Pin
Mark-12345678924-Sep-09 9:29
Mark-12345678924-Sep-09 9:29 
GeneralRe: Need help with updating SQL server express DB from c# - Done IT! Pin
PIEBALDconsult24-Sep-09 9:44
mvePIEBALDconsult24-Sep-09 9:44 
Questionhow to make check of a value in a textbox is integer or string? Pin
bounik22-Sep-09 13:41
bounik22-Sep-09 13:41 
AnswerRe: how to make check of a value in a textbox is integer or string? Pin
Wes Aday22-Sep-09 13:44
professionalWes Aday22-Sep-09 13:44 

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.