|
no, actually i couldn't understand how to get data one by one and copy to second DGV.
|
|
|
|
|
Well assuming you have the same columns set up in both tables then you can iterate through the Rows property and add each one. Something like...
foreach(DataGridViewRow row in dgv1.Rows)
{
dgv2.Rows.Add(row);
}
You would obviously need to pass the first DGV's Rows collection to the second form to be processed
Life goes very fast. Tomorrow, today is already yesterday.
modified on Thursday, November 11, 2010 8:58 AM
|
|
|
|
|
when i insert your code the following errors occured.
No row can be added to a DataGridView control that does not have columns. Columns must be added first .
and when i insert column by following code:
foreach (DataGridViewColumn c1 in dataGridView1.Columns)
{
DataGridViewColumn c2 = (DataGridViewColumn)c1.Clone();
dataGridView2.Columns.Add(c2);
}
this error occured:
Row provided already belongs to a DataGridView control.
|
|
|
|
|
OK my mistake, something like this should work...
foreach (DataGridViewRow row in dgv1.Rows)
{
object[] cells = new object[row.Cells.Count];
row.Cells.CopyTo(cells, 0);
dgv2.Rows.Add(cells);
}
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
What is the collection that is used to populate the DGV, datatable, List<>, array[] or is the DGV manually created with no underlying collection.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
In my application I need to check and disable a device if it is a USB keyboard or USB mouse. How can i know the type of the device plugged into a system?
Please advice.
Regards,
Joe.
|
|
|
|
|
Maybe you could look into WMI[^] - use google to search for your specific needs
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
|
Guys,
I am done with my .exe, now i want to setup the exe through a installer packager and update the same in Add or remove programs in Control Panel, can some body let me know the process.. I googled a lot , no use.. Please help me out...Thank u
|
|
|
|
|
If your willing to pay then MSI Factory[^] is a good tool
Otherwise you could look into WIX[^] (lots of effort) or what is available in Visual Studio[^]
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Make a Setup and Deployment to make installer package.. In that way you can have in control panel too.
|
|
|
|
|
Thanks dude... its worked ... One more thing how to create a desktop shortcut for inatalled location using this deployment...
|
|
|
|
|
Don't get too used to the Setup and Deployment project. It won't be there in the next Visual Studio.
I highly recommend you start using InstallShield Express or some other packaging tool, InnoSetup, Wise for Windows Installer, WIX, ..., in its place.
|
|
|
|
|
Hello i am using visual studio 2010. I am currently working on a project and i am stuck at the part where i must effectively remove the background of an image. I am working on images like flowers.
i am now currently using filters to filter out the background. however different image has different color values and i have no idea how to remove background for different images.
i use the follow codings:
<br />
ColorFiltering filter = new ColorFiltering();<br />
<br />
filter.Red = new IntRange(30, 100);<br />
filter.Green = new IntRange(0, 255);<br />
filter.Blue = new IntRange(0, 255);<br />
<br />
filter.ApplyInPlace(cropImage);
and every time i want to filter the image i have to change the filter values myself manually is there any way i can do it without doing it manually?
|
|
|
|
|
WOAH!!! Yesterday you couldn't do the basic task of getting MIN and MAX values for an int array and now your on to image processing!!! You must have read alot of books last night
I don't know about this ColorFiltering thing you got going on but I guess you need to calculate BG colour and use that.
Is the BG colour always going to be a solid one colour? If so you could make the assumption that the very first pixel is part of the BG, Get its colour and use that as the colour to filter.
I guess you are also assuming that the BG colour will not also be used in the parts of the image you want to keep?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
oh i manage to find out how to do the min and max of course i move on. and by the way i am very new to c# programming and my project requires me to do that so i have no choice pls understand if i post qns that might seems easy to you but it might be hard for me. I felt helpless so i turn to forum.
the background consist of many different color not one solid color.
All i know was keeping the color i want using filter(code) as shown above however i have to manually set the color. is there anyway i can do it so that it can automatic detect the colors i want to keep?
|
|
|
|
|
Its not easy for me either, I certainly don't know how to do what you need. But you just seem to be very deep in with so little knowledge.
There is a saying on my planet... "Don't jump in the deep end if you cant swim (or if your wearing iron boots without a blue tunic on)"
One tip - Code cannot guess what you what (not with 100% guarantee at least) basically you need to tell it one way or another what color(s) you want to keep.
How do you determine which colour(s) you want to keep?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
"Removing the background" is secondary to what you need to know for this. You need to do some research on edge detection algorithms in order to do this properly.
I can't really help you with that, but I think that will help you along the way.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Hi,
We're trying to figure out validation in the mvvm doing validation in the business logic or model.
I've implemented the validate by exception type in our business logic - a simplified diagram can be found here:
http://util.gubbl.com/imageupload/validate_by_exception.gif[^]
If we've got lot's of inputs that are independent of each other, there is no problem, the exception is thrown, the textbox catches it an marks it's borders red for each wrong input. However, when we've got dependent values we're in trouble.
e.g.
- Value1 and Value2 in the model must not be the same, so we've got a validate function in each of those looking for the equals value and throw an exception if that happens
- now, if we set Value1 to 0 and Value2 to 1 everything is fine
- Value1 gets set in the GUI to 1 --> this one gets marked red, because the validation of the other values is not triggered, so Value2 in the GUI is not marked faulty
- Value2 gets set to 2 in the GUI, now we've reached a valid state, but only Value2 gets validated, so Value1 still is marked as faulty
Is there a common pattern to solve that issue? we don't want to introduce a dependency in the GUI between the two textboxes, because this logic should only be present in the business logic layer.
Instead of implementing the validate by exception one could also implement the IDataErrorInfo interface, but the problem still exists, there is no way to force depending values to validate their values again, at least none that i can see
Any help is appreciated
cheers,
manni
modified on Thursday, November 11, 2010 3:08 AM
|
|
|
|
|
I have some bitmap.
I know that the bitmap format is PixelFormat.FormatXXXXXXbppRgb ==> but i want dynamically to calculate the size of each pixel.
For example ==> if the bitmap pixel format is Format24bppRgb i want to calculate that the R/G/B range is between 0 to 255.
So, i don't know how to get the information that in case of Format24bppRgb the R/G/B bit size is 3.
or that in the format is Format32bppRgb that the R/G/B bit size is 4.
P.S: i don't want to use the code
BitmapData bmDateFrame = bitmap.LockBits(....)
Int32 picPixelBit = bmDateFrame.Stride / bitmap.Width;
|
|
|
|
|
There doesn't appear to be an easy way to do this from what I can tell. but looking at the PixelFormat Enumeration[^] it is only going to be 8 or 16 bits per pixel so a small switch statement should do the job.
The bigger question is why do you need to know this? There is most likely a better way as I have never needed to know this information.
|
|
|
|
|
The size of each pixel depends only on the pixel format. You can see here[^] the lenght for each pixel format and how many bits are used for each A/R/G/B component.
|
|
|
|
|
please provide me some code to generate toolstrip like glossy sky blue color for my form's back color. lots of third party control having that color. so i just need to know how to generate that type of gradient color.help me with sample code. thanks.
tbhattacharjee
|
|
|
|
|
I am trying to write a method which will get triggered whenever there is a display settings change like resolution change, dual monitor connected and enabled etc. For this I am relying on SystemEvents.DisplaySettingsChanged event.
In the event handler, I am doing the following to detect the active display devices (got this in google search).
[StructLayout(LayoutKind.Sequential)]
public struct DISPLAY_DEVICE
{
public int cb;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string DeviceName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string DeviceString;
public int StateFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string DeviceID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string DeviceKey;
public DISPLAY_DEVICE(int flags)
{
cb = 0;
StateFlags = flags;
DeviceName = new string((char)32, 32);
DeviceString = new string((char)32, 128);
DeviceID = new string((char)32, 128);
DeviceKey = new string((char)32, 128);
cb = Marshal.SizeOf(this);
}
}
[DllImport("user32.dll")]
public static extern bool EnumDisplayDevices(
string lpDevice, int iDevNum,
ref DISPLAY_DEVICE lpDisplayDevice, int dwFlags);
const int DISPLAY_DEVICE_ACTIVE = 0x01;
const int DISPLAY_DEVICE_PRIMARY_DEVICE = 0x04;
foreach (Screen screen in Screen.AllScreens)
{
LogMsg("Display Device:" + screen.DeviceName + " " + "BPP:" + screen.BitsPerPixel.ToString() + " " + "Width:" + screen.Bounds.Width.ToString() + " " + "Height:" + screen.Bounds.Height.ToString());
DISPLAY_DEVICE monitor = new DISPLAY_DEVICE(0);
monitor.cb = System.Runtime.InteropServices.Marshal.SizeOf(monitor);
LogMsg("Cb:" + monitor.cb.ToString());
EnumDisplayDevices(screen.DeviceName, 0, ref monitor, 0);
LogMsg("State flags:" + monitor.StateFlags.ToString());
if ((monitor.StateFlags & DISPLAY_DEVICE_ACTIVE) == 0x01)
{
LogMsg("Display Device is active");
}
if ((monitor.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) == 0x04)
{
LogMsg("Display Device is primary one");
}
}
What I observed is, the StateFlags is always zero. Then how to check for the active display device?
Is there any other way to detect all the active physical display devices? Any idea whats wrong in the above method?
Also, in the event handler, how to know what caused this event? What I mean is, whether the resolution caused this event or changing to dual monitor caused this event?
Any help or pointer is appreciated.
|
|
|
|
|
This[^] will signal some of the changes you're interested in. When a second monitor is enabled/disabled showing the same image as the primary monitor, I don't expect it to fire though.
|
|
|
|