Click here to Skip to main content
15,888,977 members
Home / Discussions / C#
   

C#

 
GeneralRe: excel Pin
\laddie6-Aug-07 4:29
\laddie6-Aug-07 4:29 
AnswerRe: excel Pin
\laddie6-Aug-07 4:27
\laddie6-Aug-07 4:27 
QuestionAdd variable to object reference Pin
Rick van Woudenberg6-Aug-07 2:30
Rick van Woudenberg6-Aug-07 2:30 
AnswerRe: Add variable to object reference Pin
Luc Pattyn6-Aug-07 2:52
sitebuilderLuc Pattyn6-Aug-07 2:52 
AnswerRe: Add variable to object reference Pin
Vasudevan Deepak Kumar6-Aug-07 3:24
Vasudevan Deepak Kumar6-Aug-07 3:24 
AnswerRe: Add variable to object reference Pin
\laddie6-Aug-07 3:33
\laddie6-Aug-07 3:33 
AnswerRe: Add variable to object reference Pin
Colin Angus Mackay6-Aug-07 3:44
Colin Angus Mackay6-Aug-07 3:44 
AnswerRe: Add variable to object reference Pin
Rick van Woudenberg6-Aug-07 4:04
Rick van Woudenberg6-Aug-07 4:04 
Thank you all for you swift reply.
Very true , new would create a new instance ( hence the name ). I can understand why this could be confusing. I will try to explain as good as I can why I would want this.

I create a new array of points, which I add to a ObjectList.

private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)<br />
        {<br />
foreach (DataGridViewRow SelectedRow in dataGridView.SelectedRows)<br />
{<br />
Points pt = new Points();<br />
pt.AddPoint(X,Y);<br />
RenderableObjects.Objects.Add(pt);<br />
}<br />
}


When I rerender the form, the points (X,Y) show on the screen. So everytime I click on a row in the datagridview, the method is called. However, everytime a new instance of Points() is added to the RenderableObjects list. But before adding the new X and Y point , I want the list to be cleared. This can be achieved by :

RenderableObjects.Objects.Remove(pt);

However you can't use this line in the same method, since a new reference is initiated and therefore the previous pt is not removed.

My though was ( and it was just a though ) : If I could add a variable to the new reference, I could specifically filter, something like :

private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)<br />
        {<br />
int x = 1;<br />
foreach (DataGridViewRow SelectedRow in dataGridView.SelectedRows)<br />
{<br />
points pt[x] = new Points();<br />
pt[x].AddPoint(X,Y);<br />
RenderableObjects.Objects.Add(pt[x]);<br />
int y = x -1 ;<br />
RenderableObjects.Objects.Remove(pt[y]);<br />
x++;<br />
}<br />
}


For obvious reasons , this code would not run 'cause you cannot use an array (x) size on a variable declaration. Like I said, it was just a thought. I hope I was able to clearify it a bit more.

Cheers
QuestionProblem about debuging Pin
kcynic6-Aug-07 2:29
kcynic6-Aug-07 2:29 
AnswerRe: Problem about debuging Pin
MIHAI_MTZ6-Aug-07 4:12
MIHAI_MTZ6-Aug-07 4:12 
GeneralRe: Problem about debuging Pin
kcynic7-Aug-07 15:18
kcynic7-Aug-07 15:18 
GeneralRe: Problem about debuging Pin
kcynic7-Aug-07 19:10
kcynic7-Aug-07 19:10 
QuestionGet vs Post Pin
_AnsHUMAN_ 6-Aug-07 2:29
_AnsHUMAN_ 6-Aug-07 2:29 
QuestionDatabase and XSLT Pin
Prashant C6-Aug-07 2:12
Prashant C6-Aug-07 2:12 
AnswerRe: Database and XSLT Pin
lmoelleb6-Aug-07 7:40
lmoelleb6-Aug-07 7:40 
QuestionWhen should i use ?? Timer vs Thread.Sleep(int); Pin
Abdul Gafoor6-Aug-07 2:11
Abdul Gafoor6-Aug-07 2:11 
AnswerRe: When should i use ?? Timer vs Thread.Sleep(int); Pin
Luc Pattyn6-Aug-07 2:18
sitebuilderLuc Pattyn6-Aug-07 2:18 
GeneralRe: When should i use ?? Timer vs Thread.Sleep(int); Pin
Pete O'Hanlon6-Aug-07 3:21
mvePete O'Hanlon6-Aug-07 3:21 
GeneralRe: When should i use ?? Timer vs Thread.Sleep(int); Pin
Malcolm Smart6-Aug-07 3:27
Malcolm Smart6-Aug-07 3:27 
GeneralRe: When should i use ?? Timer vs Thread.Sleep(int); Pin
Pete O'Hanlon6-Aug-07 3:34
mvePete O'Hanlon6-Aug-07 3:34 
JokeRe: When should i use ?? Timer vs Thread.Sleep(int); Pin
Luc Pattyn6-Aug-07 3:54
sitebuilderLuc Pattyn6-Aug-07 3:54 
GeneralRe: When should i use ?? Timer vs Thread.Sleep(int); Pin
Pete O'Hanlon6-Aug-07 4:01
mvePete O'Hanlon6-Aug-07 4:01 
QuestionTreeView StateImageList StateImageIndex Pin
Abisodun6-Aug-07 2:00
Abisodun6-Aug-07 2:00 
AnswerRe: TreeView StateImageList StateImageIndex Pin
Abisodun6-Aug-07 3:41
Abisodun6-Aug-07 3:41 
QuestionAutomatical start up Pin
Albu Marius6-Aug-07 1:18
Albu Marius6-Aug-07 1:18 

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.