Solved

DataGridView, threat as array

Posted on 2008-10-11
5
526 Views
Last Modified: 2012-08-13
hi,

i have small problem.
tht generates data very fast and fills a DataGridView.
to prevent double data, can i check a value without knowing on witch row 'X' it is in  the column.

something like

i'm try to find out if out's possible to use a DataGridView as a type of Multi array.
something simular to sql, insert, update and select wihtout looping.


public void Fill_Grid(string data)
{
if(this.DataGridView1.Rows['X'].Column[0].Value == data)
{
// omit
}
else
{
// add some more
}
}

Open in new window

0
Comment
Question by:Natural_Demon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 125 total points
ID: 22693031
datagridview does not have a facility for this, but you can keep a dictionary in parallel to store the keys.

Dictionary<string, bool> yourKeys = new Dictionary<string, bool>();

indeed the bool value doesnt matters, but you can use it for something.
To add a key to the dictionary:

yourKeys.Add(somekeyhere);

to previously check if key exists:

if (yourKeys.ContainsKey(somekeyhere)) ...
0
 

Author Comment

by:Natural_Demon
ID: 22693345
yes, i know
but i use 5 dictionary's
i'm trying to visualize the data.
 
and the code below only works on 1 dictionary.
 
kind regards
 
 

            foreach (KeyValuePair<uint, int> Pair in local_steal_data)
            {
                Grid.Rows.Add(Pair.Key, Pair.Value, "0");
                ++i;
            }

Open in new window

0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22694680
what you intend to do can be best done if you are binding your datagridveiw to a datatable as you can fire sql to your datatable and then rebind the datagridview

i really dont know what kind of data you are dealing with currently and what is the complexity of data but your life will become a lot simpler if you can have a datatable.
0
 

Author Comment

by:Natural_Demon
ID: 22739073
@ragi0017
the programma is connected via dll to a popular vistual world "second life", once you connect to a simulator, a burst of data comes in.
lots of data, segarding the simulator your connected to, a normal simulator has 15.000+ objects capacity, called primatives.
so i get al this data, (if my program had a visual interface, to build a view of the simulator.), but i have no visual interface.
but i'm intrested in certained objects.

i tried with sqlite, but the harddisc get to do overtime and eventualy will produce 'database locked' message.
i'll post a thread on this soon.
@jaime_olivares
thanx for pointing that out, i think there might be a work around, but having a dictionary walking paralel to the datagrid.
dictionary<uint localid, int rownumber>
once u know the line number of the grid, it's easy to get the relational data corresponding to 'localid'.
i haven't test it, but i think in theory it's possible.
and possible faster than a real big burst of data.
0
 

Author Closing Comment

by:Natural_Demon
ID: 31505272
thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question