|
I tried to only remove the item, but the program still executes the selectindexchanged statement.
I get the error NullRefefenceException.
~ Bizarre what men fin attractive ~
|
|
|
|
|
int index = listBox1.SelectedIndex;
if (index >= 0)
{
listBox1.Items.RemoveAt(index);
Reestablecer();
int lastItem = listBox1.Items.Count - 1;
if (index > lastItem)
{
listBox1.SelectedIndex = lastItem;
}
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
your code worked fine! Now i just need to check it few more times, because after i delete few items it gets again the null reference exception
thank you
~ Bizarre what men fin attractive ~
|
|
|
|
|
Try this:
int index = listBox1.SelectedIndex;
if (index >= 0)
{
listBox1.Items.RemoveAt(index);
Reestablecer();
int lastItem = listBox1.Items.Count - 1;
if (lastItem >= 0)
{
if (index > lastItem)
{
listBox1.SelectedIndex = lastItem;
}
}
else
{
listBox1.SelectedIndex = -1;
}
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Or this:
int index = listBox1.SelectedIndex;
if (index >= 0)
{
listBox1.Items.RemoveAt(index);
Reestablecer();
int lastItem = listBox1.Items.Count - 1;
listBox1.SelectedIndex = Math.Min(lastItem, index);
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I am using a datatable to populate a datagrid in VS2003.
I need to select a row if any cell within the grid is clicked.
I use DataGrid.Select(RowNum) to select the rows & it works on the first selected row, but if i try clicking on any other cells to select a second row, the first selection goes away.
I use ctrl+click for multiple selections.
Can someone help me with the multiple selections.
Thanks.
|
|
|
|
|
Listen, do you mean focus some rows? why that?
query your table to get only those rows in the grid? after all you are creating a condition, to select only 3 rows
Can you focus those rows with a color?
I really dont know how to help i dont know what you are doing! maybe some one can help you there.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hi all
Im trying to create a My favorite folder tab just the one outlook has but i don`t how to write the code for it.
Thank You in advance
|
|
|
|
|
craigMUTOKOKAI wrote: but i don`t how to write the code for it.
Hmmm, yes I can see how that is a problem, for you. What do you think you should do about that?
led mike
|
|
|
|
|
It shouldn't be a problem really, he's already asked how to get email from an exchange server, create a task list and create a calender control like outlook etc, so I expect someone will help him with his college coursework
Bob
Ashfield Consultants Ltd
|
|
|
|
|
hi.
I have a view that binded to a gridview.
i want to add directly in Datagrid and then the new row added to corresponded table.
what should i to do?
sepel
|
|
|
|
|
sepel wrote: what should i to do?
You should learn how Data Binding works. There are mountains of documentation and tutorials with sample code on MSDN and well as in Articles here on CodeProject.
led mike
|
|
|
|
|
i know about binding but how about bind to a view?
sepel
|
|
|
|
|
Works the same as binding to a table
|
|
|
|
|
sepel wrote: how about bind to a view?
READ THE FREAKING DOCUMENTATION AND STOP TYPING INTO INTERNET FORUMS!!!!!!!!
Oh, and have a nice day.
led mike
|
|
|
|
|
led mike wrote: You should learn how Data Binding works.
you took the words right out of my mouth.... This is far to genral a question,
|
|
|
|
|
Hi,
I'm calling a web service method from an application with no problems. However, when there are network problems (ie the Web Service can;t be reached), the method "timeout" is too long and the application hangs for about a minute, before giving the error that the server could not reached or does not exist. Is there any way I can prevent this behaviour? Maybe by reducing the timeout?
Thanks in advance,
Daniel
|
|
|
|
|
Hi,
I am working in a project where we need to store some data of the position of some points. This data is received with a freqüency of 100Hz, and each point is part of a movement. The two problems related with that is that the length of the movement is not known (variable amount of time to store the movement = array of positions), and that we are "free" to store the information as we want.
Is there any method relatively easy to use to store that position information for posterior processing? It is: to add information with time, with a variable amount of time (variable size of the array of positions) in C#? Methods/technique name so I can focus my research? Any guess?
Thank you!
|
|
|
|
|
TaSsl wrote: Methods/technique name so I can focus my research? Any guess?
Sure, search for Collections or Containers. Good luck with your school assignment.
led mike
|
|
|
|
|
How can I disable the Print button when PrintPreivewDialog window is opened. It's built in with PrintPreviewDialog and I couldn't find any way to do it. Does anybody know how to do it.
Thanks
|
|
|
|
|
Hi All
i have a calendar on one form and i have a schedule on another form. When a use clicks on a date on the calendar or dobule clicks it i want it to open the Schedule form.
Does any one know how to do this ?
Thanks in advance
|
|
|
|
|
add an event handler to the double clikc on the date time form then in the event handler open the form and pass what ever parameters you want to
|
|
|
|
|
I have tried that but no luck.
Thanks
|
|
|
|
|
Can you post the code that you used?
Did you get an exception when you tried it? If yes, please post the message here
|
|
|
|
|
I am trying to write the code but i don`t know what to write. Im very new at c#.
|
|
|
|