dataGridView.Rows.Count and datagridview.RowCount

C#

    Next

  • 1. efficient access to same data within multiple classes
    Hi guys, First, I'm a newbie :) I've been trying to create an application using C#. The application has 2 classes. Class A and class B. Class A will read a file and store the data in a byte array. Then based on user action, class A will create class B and pass the byte array as constructor parameter. class A: { ... byte[] data; ... createB(data); ... } class B: { public B(byte[] data) { ... DoProcess(data); ... } } The problem is every time the class B is created, it seems to create a new instance of byte array, which then takes memory resource. For example, if the byte array is 10MB in size and I have 5 class B created, it takes, at least, 50MB of memory ( as I can see in the task manager ). Hence, the application becomes memory hungry. How can I make the byte array as 'static' reference so class B won't need to create a new instance of it every time it is created? Thanks. Note: the real application is a tabcontrol based winform application. The byte array will be needed for each tab page to do some processing. Class A is the main form, and Class B is class that extends TabPage.
  • 2. DCOM from .Net
    Hello Ashutosh I'm not sure that I understand the question rightly. Do you mean how to dynamically specify the server name of a remote COM object? In C#, Type.GetTypeFromProgID([prog ID], [server name]); supports specifying the server name. We can place the value in a config file, and dynamically pass it to the second parameter of Type.GetTypeFromProgID. Is this what you are looking for? Please provide me with more details of the request. Regards, Jialiang Ge ( XXXX@XXXXX.COM , remove 'online.') Microsoft Online Community Support ================================================= Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: XXXX@XXXXX.COM . This posting is provided "AS IS" with no warranties, and confers no rights. =================================================
  • 3. Kill proof application
    Hi, I have developed an application which does some scaning activity on users machine and dumps data on server. Application has to run in user context. This is requirment of an application. This application performes well as long as it is running. how do we make this application kill proof so that user can not kill from process explorer and taskmanager. 1 I have considered the changing the owner of the application. but this will fail because of my above (Current user) requirment. 2 I have considered WMI watch applications; This works well as long as multiple exes are running. but user still can kill all using process explorer. Application is developed in c# so any hint will be appreciated to make non killabale exe. Is it possible to create a non killable exe in c# which will not disturb windows shutdown process. Regards,
  • 4. Timer.Dispose
    Looking for someone to spend a minute to review the below code. I have a class with a collection of System.Threading.Timers that I need to Dispose of and be certain they are disposed before continuing. The class has the following variable private List<Timer> timerList = new List<Timer>(); This code is executed an unknown number of times: Timer t1 = new Timer(timerDelegate, null, 1000, 250); timerList.Add(t1); This code tried to dispose of all the timers in the collection private void DeleteTimers() { if (timerList.Count > 0) { int index = 0; WaitHandle[] waitList = new AutoResetEvent[timerList.Count]; foreach (Timer timer in timerList) { WaitHandle wh = new AutoResetEvent(false); waitList.SetValue(wh, index++); timer.Dispose(wh); } WaitHandle.WaitAll(waitList); timerList.Clear(); } } Any help would be much appreciated.
  • 5. Class structure
    I am writing a class which connects to a database, then runs a stored procedure and returns the results in a dataset. Now I am quiet new to C#, and I was wondering is it better to create my database connection within a constructor (of which I have 3) or create the connection out side the constructors in a separate function which I call in each constructor.

dataGridView.Rows.Count and datagridview.RowCount

Postby SePp » Wed, 16 Jan 2008 19:05:17 GMT

Hello all,

I want to display the number of items in an datagridview. I use this
one datagridview for different datasets.


The datagridview.Rowcount works fine for the most of the dataset. But
there is one dataset which has more items
than the others and the Rowcount wont work. The result is all the time
0, but it should be something like 85.

// Datsource
this.dataGridView1.DataSource = this.REMINDERBindingSource;
this.v_REMINDERTableAdapter.Fill(this.subnr.REMINDER);

// Display number of items
lbl_row.Text = dataGridView1.RowCount.ToString();
MessageBox.Show(this, dataGridView1.Rows.Count.ToString());

Has somebody an Idea?  Thanks in advance.

Greets
SePp

Similar Threads:

1.dataGridView.Rows.Count and datagridview.RowCount

On Jan 15, 11:05燼m, SePp < XXXX@XXXXX.COM > wrote:
> Hello all,
>
> I want to display the number of items in an datagridview. I use this
> one datagridview for different datasets.
>
> The datagridview.Rowcount works fine for the most of the dataset. But
> there is one dataset which has more items
> than the others and the Rowcount wont work. The result is all the time
> 0, but it should be something like 85.
>
> // Datsource
> this.dataGridView1.DataSource = this.REMINDERBindingSource;
> this.v_REMINDERTableAdapter.Fill(this.subnr.REMINDER);
>
> // Display number of items
> lbl_row.Text = dataGridView1.RowCount.ToString();
> MessageBox.Show(this, dataGridView1.Rows.Count.ToString());
>
> Has somebody an Idea? 燭hanks in advance.
>
> Greets
> SePp

I have a solution....

I don't use the count for the datagridview I use the Dataset instead:

 MessageBox.Show(this, this.dataset_name.Rows.Count.ToString());

Thanks

2.Datagridview confused on row count

I have a windows form with the datagridview that displays data from a
single table. The underlying data can be updated/deleted from another
component.

In our case, we raise an event when any underlying changes happen. We
then have been trying to refresh our grid without much luck.

We use:
this.DataSet.Offers.Clear();
this.offersTableAdapter.Fill(this.DataSet.Offers);
this.offersBindingSource.ResetBindings(false);
this.offersDataGridView.Refresh();

We have tried multiple variations but the underlying data is fairly
small. Unfortunately, if a row is deleted often the grid will then
think that two rows have been deleted. If the grid is refreshed a
second time, then the correct rows are shown.

Can someone suggest the proper way to go about this or point out the
error in our refresh syntax?

Thanks

3.DataGridView.RowCount setting is slow

I have DataGridView in virtual mode containing 3500 rows.
In code below, assigning to RowCount value to 3500 takes 8 seconds.
CPU usage goes high at this time.
Stepping by F11 into user code shows few celltemplate property getters and
combobox/datecombo constructor calls without database access  which does not 
take a lot of time.

Debug output (below)  shows lot of messages Stepping over non-user code.
Running in release mode from Windows this line speed is same (slow).

How to speed up grid creation ?

Using C# Express 2008 3.5 SP1 in Vista.

Andrus.

class Grid : System.Windows.Forms.DataGridView {

        internal void SetDataRetriever(DataRetriever<TEntity> dataRetriever)
        { ......
            SuspendLayout();
            Enabled  = false;
            int cnt = DataRetriever.RowCount + (ReadOnly ? 0 : 1);
            // next line takes 8 seconds:
            RowCount = cnt;
            Enabled = true;
            ResumeLayout();
        }

        protected override void
OnCellValueNeeded(DataGridViewCellValueEventArgs e)
        {
            if (!Enabled)
                return;
             ...
        }

        protected override void OnRowEnter(DataGridViewCellEventArgs e)
        {
            if (!Enabled)
                return;
            ...
         }
}

Debug output window contains:

Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.RowCount.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewColumn.CellTemplate.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewColumn.CellTemplate.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.DataGridViewTextBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.PropertyStore.GetObject'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewCell.Style.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewColumn.CellTemplate.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewColumn.CellTemplate.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.DataGridViewTextBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.PropertyStore.GetObject'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewCell.Style.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewColumn.CellTemplate.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewColumn.CellTemplate.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.DataGridViewTextBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.PropertyStore.GetObject'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewCell.Style.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.DataGridViewComboBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.FlatStyle.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.DisplayStyleForCurrentCellOnly.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewColumn.CellTemplate.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewColumn.CellTemplate.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.DataGridViewTextBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.PropertyStore.GetObject'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewCell.Style.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.DataGridViewComboBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.FlatStyle.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.DisplayStyleForCurrentCellOnly.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.CompleteCellsCollection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.RowTemplateClone.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRowCollection.Add'
Step into: Stepping over non-user code
'System.Windows.Forms.Control.Enabled.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.OnRowEnter'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.SetCurrentCellAddressCore'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.SetAndSelectCurrentCellAddress'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.DataGridViewTextBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.PropertyStore.GetObject'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewCell.Style.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRow.CloneCells'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.DataGridViewTextBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.PropertyStore.GetObject'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewCell.Style.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRow.CloneCells'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.DataGridViewTextBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.PropertyStore.GetObject'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewCell.Style.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRow.CloneCells'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.DataGridViewComboBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.FlatStyle.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.DisplayStyleForCurrentCellOnly.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRow.CloneCells'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.DataGridViewTextBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.PropertyStore.GetObject'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewCell.Style.get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewTextBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRow.CloneCells'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.DataGridViewComboBoxCell'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.FlatStyle.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.DisplayStyleForCurrentCellOnly.set'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewComboBoxCell.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRow.CloneCells'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRow.Clone'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRowCollection.this[int].get'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.SetSelectedCellCore'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.SetSelectedElementCore'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.ClearSelection'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.SetAndSelectCurrentCellAddress'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridView.OnRowCollectionChanged_PostNotification'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRowCollection.InsertCopiesPrivate'
Step into: Stepping over non-user code
'System.Windows.Forms.DataGridViewRowCollection.Add'

4.datagridview's rowcount in virtualmode

5.Copy current row values to new row in DataGridView

User can add new row to Winforms DataGridView by pressing Ctrl+down arrow

How to initialize some new row values from current row ?

How to get last row number which was current if Ctrl+Down arrow key was 
pressed ?

Andrus. 

6. Adjusting DataGridView row heights on existing rows

7. Class Inherits DataGridView, Errors: Rows(0).DataGridView

8. 2.0Beta DataGridView: Strange behaviour for RowCount property



Return to C#

 

Who is online

Users browsing this forum: No registered users and 94 guest