From: leinchu on

I have the samilor problem,but I resolved it;
1. Do not remove the row you want to remove directly,just store it in
an array;
Codes are like below:
private int[] delIndex = null;
pushDelIndex(row.CurrentRow.Index);
private void pushDelIndex(int _index){
if(delIndex==null){
delIndex=new int[]{_index};
}else{
Array.Resize(ref delIndex,delIndex.Length+1);
delIndex[delIndex.Length - 1] = _index;
}
}

2. Then open a thread when the program start;
Codes are like below:
Thread delTh = new Thread(new ThreadStart(delRowThread));
delTh.Start();

3. Use the thread to check the array delIndex every 100 millseconds??if
it is not null,the call the function delRow;
Codes are like below:
void delRowThread() {
while (delFlag) {
if (delIndex != null) {
if (deling == false)
{
delRow();
}
}
Thread.Sleep(100);
}
}

private delegate void delRowCallBack();
void delRow() {
if (PlayList.InvokeRequired)
{
deling = true;
delRowCallBack o = new delRowCallBack(delRow);
this.Invoke(o);
}
else {
for (int i = 0; i < delIndex.Length; i++) {
PlayList.Rows.RemoveAt(delIndex[i]);
}
deling = false;
delIndex = null;
}
}



Martin B wrote:
> *Hallo to everyone!
>
> Problem:
> --------
> GridView Exception: reentrant call to the SetCurrentCellAddressCore
> function
>
> System:
>
>
> Martin *



--
leinchu
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1702096.html

From: leinchu on

I have the samilor problem,but I resolved it;
1. Do not remove the row you want to remove directly,just store it in
an array;
Codes are like below:
private int[] delIndex = null;
pushDelIndex(row.CurrentRow.Index);
private void pushDelIndex(int _index){
if(delIndex==null){
delIndex=new int[]{_index};
}else{
Array.Resize(ref delIndex,delIndex.Length+1);
delIndex[delIndex.Length - 1] = _index;
}
}

2. Then open a thread when the program start;
Codes are like below:
Thread delTh = new Thread(new ThreadStart(delRowThread));
delTh.Start();

3. Use the thread to check the array delIndex every 100 millseconds??if
it is not null,the call the function delRow;
Codes are like below:
void delRowThread() {
while (delFlag) {
if (delIndex != null) {
if (deling == false)
{
delRow();
}
}
Thread.Sleep(100);
}
}

private delegate void delRowCallBack();
void delRow() {
if (PlayList.InvokeRequired)
{
deling = true;
delRowCallBack o = new delRowCallBack(delRow);
this.Invoke(o);
}
else {
for (int i = 0; i < delIndex.Length; i++) {
PlayList.Rows.RemoveAt(delIndex[i]);
}
deling = false;
delIndex = null;
}
}



Martin B wrote:
> *Hallo to everyone!
>
> Problem:
> --------
> GridView Exception: reentrant call to the SetCurrentCellAddressCore
> function
>
> System:
>
>
> Martin *



--
leinchu
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1702096.html