|
hello ,
Am tring to use Excel SpreadSheet on the Windows form. The datasource is a datatable. While am giving the datasource as Datatable it is not working . It is asking for MSDATASRC. Any one knows how to convert Data Table to MSDATASRC..
|
|
|
|
|
These are some C# class members:
[StructLayout(LayoutKind.Sequential)]
unsafe struct MyStruct
{
public int size;
public byte* data;
}
[DllImport("MyStruct.dll", CharSet = CharSet.Unicode)]
static extern unsafe void MyFunction(MyStruct* myStructs, unsigned int nMyStructs);
How to create such array of MyStruct in C# as in C to pass it to MyFunction from C#?
unsigned int N = 10;
MyStruct* pMyStructs = (MyStruct*)malloc(N * sizeof(MyStruct));
MyFunction(pMyStructs, N);
Чесноков
|
|
|
|
|
you need to rewrite the MyStruct in C# using the MarshalAs attribute at the vars declaration.
something like above its only a example ^^
you need to take a look at the mapping of your C byte* to C#..
<br />
[StructLayout(LayoutKind.Sequential)]<br />
unsafe struct MyCSharpStruct<br />
{<br />
public int size;<br />
public IntPtr data;<br />
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]<br />
public string MyString;
}<br />
<br />
[DllImport("MyStruct.dll")]<br />
static extern void MyFunction(ref MyCSharpStruct myStructs, unsigned int nMyStructs);<br />
|
|
|
|
|
You can allocate the memory whereever you want. A simple solution might be to allocate it in managed memory as .NET array:
MyStruct[] myStructs = new MyStruct[N];
fixed (MyStruct* pMyStructs = myStructs) {
MyFunction(pMyStructs, N);
}
In this case, the GC will take care of freeing the memory.
You can also allocate on the stack (if N is small, for large N you would risk a stack overflow):
MyStruct* pMyStructs = stackalloc MyStruct[N];
MyFunction(pMyStructs, N);
In this case, the memory is freed immediately when leaving the function that allocated it.
If you want to allocate in the unmanaged heap, then use one of the allocation functions in the Marshal class:
IntPtr memory = Marshal.AllocHGlobal(N * sizeof(MyStruct));
try {
MyStruct* pMyStructs = (MyStruct*)memory.ToPointer();
MyFunction(pMyStructs, N);
} finally {
Marshal.FreeHGlobal(memory);
}
You could use Marshal.Copy to copy data from a managed array to an unmanaged pointer - but if you already have a managed array, you can simply use the first approach (fixed statement) to pass that without having to copy anything.
|
|
|
|
|
hi there,
Could anyone please give me a simple example of bluetooth transfer with c#?
i have googled that but no useful results.
my devices which i want to have the transfer are a hand held computer with windows mobile and the common PC with win xp or 7.
|
|
|
|
|
You can use 32feet.net or brecham obex fro transferring files to bluetooth device.
|
|
|
|
|
how to create picture boxes dynamically and display the pictures from sql server 2005.
pls help me.
thanks............
vamsi
|
|
|
|
|
You might want to take a look here[^].
|
|
|
|
|
You know how some website login forms change the color of textboxes you left empty to red?
I want to do that in my application.
Basically after entering data you can click a "check" button that is supposed to highlight empty textboxes in red.
I tried using a graphics object and draw rectangles above the textboxes, but it doesn't work well. Not the entire border is highlighted, but only the right and lower side.
|
|
|
|
|
Well,
I haven't done that but I must ask, why not use an error provider?
Just find the Error Provider[^] in your toolbox and drop one on your form.
Then you can use something like this to set the error when they click 'check'.
myErrorProvider.SetError(myTextBox, "Not Valid");
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
|
Another possibility is to place an asterisk (* ) in the text or color the boxes when the form is populated. Then in the Validating event, change the color, etc. if the result is valid. The color can be changed by setting the BackColor property, but you may need to refresh or Invalidate() the control to see the change.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
if it is a website, I would do this in client side code instead of server code. (saves a round trip to the server)
Add a validation function that is called on the onchange event for that control that will do some basic checking (empty fields, phone number formatting, etc...) and color the control accordingly. Alternatively you can skip the onchange event and put the validation when the form is submitted.
V.
|
|
|
|
|
It's not a website, it's a windows forms app.
I'm currently changing the backcolor to red and forecolor to white (when you change the text, the color also changes back to normal) but that looks kinda awkward.
If possible I'd like to use the more elegant way of just coloring the frame of the textbox/drawing a frame around it.
How does the blinking look? It's quite possible that there'd be like 5 textboxes on a form which require input and all of them blinking at the same time would probably weird and confusing.
I want a simple, yet obvious visual hint that there is something wrong.
|
|
|
|
|
Then use the ErrorProvider, just run some tests.
The ErrorProvider, see my previous reply, is a windows forms control so i dont really understand the
Megidolaon wrote: It's not a website, it's a windows forms app.
comment
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
One day somehow i was ended up downloading microsoft C# learning. It had bunch of modules. But those are no longer available to download. Does anyone know how can we download. It was great telling everything visually.
Some of these courses are here but they charge
link
|
|
|
|
|
You haven't said exactly what you downloaded or where you got it from. Therefore, it's impossible for anyone to know what you're talking about or how to help you.
|
|
|
|
|
can I make zooming in the form itself ?
hi,
I have the following problem , I am reading from serial port and draw plots from the serial port in the form and no problem with flicker (I am enable doublebuffersize property) after doing this i does n't have any problem but the problem come when i want to make zooming in the form so I am draw in panel or picturebox but the problem of flicker appear as long as i am extend picturebox as a control and add in the constructor the following method :
Code:
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
so my question can I make zooming in the form itself if i can not what is the solution for flicker ?
|
|
|
|
|
Usually flickering occurs from trying to redraw the entire area. Make sure you only invalidate the regions that need to be invalidated instead of the entire control. That is the only way, in GDI+, to control flicker that I have found. If you need really fast drawing code (more than 15FPS) you need to use DirectX or OpenGL.
|
|
|
|
|
I guess this is quite obvious, but besides making sure that you only redraw the desired area and not the whole control, make sure that you are not reading from the serial port un the UI thread.
Long processes can interfere with the drawing of the form.
|
|
|
|
|
Hi There,
I created a ComboBox by dropping the table onto the form from "datasources"(First set type to combo). The Data displayes correctly but when I use the dropdown it tries to insert the selected value into the dataset (which obviously already exists so it throws an exception) I have not set the update/insert text on the table adapter and "allownew" property is set to no. I just want the combo to display the table content and get a selection from it afterwards, but I don't want the combo changing the dataset itsself. Why does it do this?
Kind regards
Shane Scott
|
|
|
|
|
Because data binding sucks.
The better answer is that data binding and combo boxes really sucks. I usually give up with regard to combo boxes because they are so easy to use without binding, in-fact, it takes less code and no effort to understand. One thing you can try is to change the type of your combo box to Drop Down list.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: Because data binding sucks
I thought it was just me!
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
I always use a manual data-bindings ,
Because it's had a very ugly behavior with some control ( like Comboboxs, DateTime Controls , etc ) ....
I know nothing , I know nothing ...
|
|
|
|
|
DaveyM69 wrote: Ennis Ray Lynch, Jr. wrote:
Because data binding sucks
I thought it was just me!
What? You think you're the only thing that sucks?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|