|
Hello again.
This is how I now try to do it
public void WritePixel(int color,int x, int y)
{
Array surfaceContents = _surface.Lock(LockFlags.SurfaceMemoryPointer);
int offset = ( x ) + ( _surface.SurfaceDescription.Pitch * y);
surfaceContents.SetValue(color,offset);
_surface.Unlock(null);
}
However I get an error that says lock doesn't return Array, although that it is what is stated in the ms documentation. Is this a bug or am I just doing things the wrong way?
Thanks.
|
|
|
|
|
It's of *type* Array, but think of it more as an Array of *something*.
As in:
Array == int[], or byte[,], etc.
Actually, if memory serves, Surface.Lock actually returns a 2D byte array, but my memory sucks, so check through Google to make sure.
If I'm right:
byte[,] surfaceContents = Surface.Lock(LockFlags.SurfaceMemoryPointer);
Good luck
Jeremy Kimball
I have traveled the gutters, lo these many days, with no signs of life. Well met.
-brianwelsch
|
|
|
|
|
I have a Custom Collection based on IList, so I can bind it to a datagrid. But if I change an item in the collection the information on the grid doesn't change.
How can I get this to work, like the dataset databinding works? If I update an item in a datatable in a dataset the grid gets updated instantly.
"Every rule in a world of bits and bytes can be bend or eventually be broken"
|
|
|
|
|
|
Hi all,
I have seen lots of articles on the subject of datagrid controls and check boxes. I am currently designing a goods movement system for the company i work for and i have most of it finished. However, on the last page i want to display a datagrid control with data that has been entered on previous pages, that bit i have done including formatting the datagrid (which took some figuring out but i got there in the end).
The user will have to go through each entry every week and tick them off one by one. I have added a DataGridBoolColumn object to the TableStyle.GridColumnStyles collection and the check box displays fine. However i have 2 problems.
1. The default value for the check boxes is true, i need it to be false and setting the value to false when setting up the column in code doesn't work. Although by answering the next question this might be solved.
2. Whenever i tick/untick the box then move the focus away from the cell in the grid the checkbox returns to a checked state.
any help that you can give me would be appreciated.
Cheers
KP
|
|
|
|
|
You don't have it bound to a data column correctly. The default value only applies when the data the column is bound to doesn't already have a value. Likewise, if it's not bound correctly it always appears checked.
Read the documentation for the DataGrid.DataSource and DataGrid.DataMember properties about binding data - any IList or IListSource implementation like a DataSet or DataTable - to the DataGrid , as well as the DataGrid.TableStyles about how to apply table styles to a particular data source.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath,
thanks for your advice but i have already bound the DataGrid to a DataSet
dataSAR.DataSource = gmb.gmbSet;
dataSAR.DataMember = "SAR";
Then i set up a DataGridTableStyle , mapped it to the table.
DataGridTableStyle sarStyle = new DataGridTableStyle();<br />
sarStyle.MappingName = "SAR";
Next i created a DataGridBoolColumn object and mapped it to the corresponding column in the table
DataGridBoolColumn checkColumn = new DataGridBoolColumn();<br />
checkColumn.MappingName = "Checked";
Finally i added the column to the TableStyle and added the TableStyle to the DataGrid.TableStyles collection.
sarStyle.GridColumnStyles.Add(checkColumn);<br />
dataSAR.TableStyles.Add(sarStyle);
I think that this is the correct way of going about this but i am having the problems mentioned in the above post so any advice about what i am doing wrong would be appreciated.
Cheers
KP
|
|
|
|
|
Make sure the TrueValue and FalseValue properties are set to whatever you use for true and false values. These values are case-sensitive.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How would that affect me checking / unchecking the check box at runtime? When i uncheck the box at runtime, as soon as the focus goes to another part of the form the box is checked again.
KP
|
|
|
|
|
It's called data-binding. Controls are bound to data, which is updated when the control is changed and vice versa. If the true/false values are not the same for both, the value can't be bound.
Read the class documentation for the DataGridBoolColumn in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath,
I have set the default true/false values for the DataGridBoolColumn to lower case true and false so that they match with the Value applied when a check box is checked / unchecked and it appears to work.
Thanks for all your help, i really don't think i would have figured this one out by myself.
KP
|
|
|
|
|
Hi all,
I have seen lots of articles on the subject of datagrid controls and check boxes. I am currently designing a goods movement system for the company i work for and i have most of it finished. However, on the last page i want to display a datagrid control with data that has been entered on previous pages, that bit i have done including formatting the datagrid (which took some figuring out but i got there in the end).
The user will have to go through each entry every week and tick them off one by one. I have added a DataGridBoolColumn object to the TableStyle.GridColumnStyles collection and the check box displays fine. However i have 2 problems.
1. The default value for the check boxes is true, i need it to be false and setting the value to false when setting up the column in code doesn't work. Although by answering the next question this might be solved.
2. Whenever i tick/untick the box then move the focus away from the cell in the grid the checkbox returns to a checked state.
any help that you can give me would be appreciated.
Cheers
KP
|
|
|
|
|
i have some questions regarding thread termination. i am giving a user the ability to stop a test case (thread) at any given time. my test cases have tendencies to be in long blocking states (eg, long I/O, or just waiting up to an hour for a certain response). i want the user to be able to abort out of these states. what is the best way? if i carefully clean up everything in the ThreadAbortException catch clause, is it considered OK to explicitly call Thread.Abort on the thread? or should i opt for the passing in of a manualresetevent and checking at the top of the loop, and if in blocked state use thread.interrupt instead?
|
|
|
|
|
Close the resource that the I/O is blocking on. That should unblock the thread and an error condition should also exsist that you can use logically to determine that you need to exit the thread.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
|
my program use treeView control to display as active directory object browser.
it's still fine as i have one treeView control in mainform,but i have problem when i start to include treeView in another form(created from mainform like dialog).
the window almost look not responding when i refresh the second treeView control. i really need help
if you are not clear about what my problem is please let me know
really appreciate the help.
if you have active directory installed, maybe you could help examine my program.
thanks
|
|
|
|
|
|
i download the file, and it's corrupted..what should i do?
|
|
|
|
|
Both files are fine. I download them and unzipped them with no problems. Try downloading them again.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i can download the file, but when i can't unzip, the report is unknown compression.
maybe you could do me a favor send to my email vcorn8@yahoo.com
Thank you
|
|
|
|
|
Try downloading a free app that can use the .zip extension. Winzip has a free copy (bugs you after 30 days) that can work with Zip files!
Yes, I program in VB, but only to feed my addiction to a warm place to sleep and food to eat!
Visit my Code Project blog (Mobile Audio project)[^]
|
|
|
|
|
Because of restrictions on email where I work, no, I can't.
Besides, I'd be sending you another .ZIP file, more than likely with the same compression, or I'd be sending the same .ZIP file. Do you have WinZip? Then it should work with no problems. Don't rely on the ZIP functionality built into Windows XP and above...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i have winRAR
it seems it's my internet connection, it took me a while to open codeproject site, i'd be glad if u could send to my mail.
i just wanna know whether he use threading or not.
i found sometimes the work done to active directory is very fast in my program and sometimes run very slow like not responding and i believe it has to do with GUI updating
|
|
|
|
|
Get WinZip. It's worth the trouble to download it. I can't send attachments from work to the outside Internet...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I am writing a project that runs code from several assemblies.
Each assembly should be isolated, and the project supposes to be lightweight, therefore I am running one process and each assembly runs in a different AppDomain.
The project suppose that an assembly may crash or stack and uses the AppDomain.Unload() method to remove an AppDomain to release its resources.
I got to a problem once I tried to unload an AppDomain while a thread, that belonged to it, was waiting on a MessageQueue.Receive(). The AppDomain threw the CannotUnloadAppDomainException exception and didn't unload, or at least not gracefully.
The problem happens when a thread waits on a message queue and cannot be aborted, interrupted, or terminated forcefully. I didn’t try it, but I believe that the same happens when the thread waits for other things that use internally unmanaged code such as sockets.
How can I unload these AppDomains?
How can I force a thread to exit code that suppose to be managed such as MessageQueue.Receive() and Socket.Receive()?
Thanks,
Ami
|
|
|
|