|
Thanks alot Strahil Shorgov!!
|
|
|
|
|
I want to pass text of a combobox in my form to crystal report to use as header title.
How can I do this?
|
|
|
|
|
Hi,
Here is the code snippet:
CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
reportDocument.Load("samplereport.rpt");
reportDocument.SummaryInfo.ReportTitle = comboBox1.Text;
reportDocument.SetDataSource(dset);
crystalReportViewer1.ReportSource = reportDocument;
Thanks,
Gopal.S
|
|
|
|
|
|
I'm writing a C# plugin for a C app, which has well defined API's, structures, etc. I'm trying to figure out how to use a icon / image resource in my C# project and properly convert it to the C struct.
For example, the C struct I have to use is:
struct medium_entry<br />
{<br />
unsigned int struct_size;<br />
<br />
char *medium;<br />
char *description;<br />
int allows_accounts;<br />
int allows_connections;<br />
<br />
ttkCallback callback;<br />
void *data;<br />
<br />
unsigned char *png_image_32;<br />
unsigned int png_image_32_len;<br />
unsigned char *png_image_16;<br />
unsigned int png_image_16_len;<br />
};
Here is the C# representation of that struct, which the P/Invoke Interop Assistant tool (winsiggen.exe) generated for me:
<br />
[StructLayoutAttribute( LayoutKind.Sequential )]<br />
public class medium_entry<br />
{<br />
public uint struct_size;<br />
<br />
[MarshalAsAttribute( UnmanagedType.LPStr )]<br />
public string medium;<br />
<br />
[MarshalAsAttribute( UnmanagedType.LPStr )]<br />
public string description;<br />
<br />
public ttkCallback callback;<br />
<br />
public System.IntPtr data;<br />
<br />
[MarshalAsAttribute( UnmanagedType.LPStr )]<br />
public string png_image_32;<br />
<br />
public uint png_image_32_len;<br />
<br />
[MarshalAsAttribute( UnmanagedType.LPStr )]<br />
public string png_image_16;<br />
<br />
public uint png_image_16_len;<br />
<br />
public medium_entry_t()<br />
{<br />
this.struct_size = (uint)Marshal.SizeOf( typeof( medium_entry ) );<br />
}<br />
}<br />
Here is sample code on how the image would be loaded in C:
<br />
HRSRC ImageRes;<br />
data *medium_entry;
HMODULE hInstance;
<br />
ImageRes = FindResource(hInstance, MakeIntResource(102), "PNG");<br />
data->png_image_32 = LockResource(LoadResource(hInstance, ImageRes));<br />
data->png_image_32_len = SizeOfResource(hInstance, ImageRes);<br />
I've tried two different methods of loading up an image and storing it in the medium_entry class, but neither have worked in the C app, so I assume I'm doing something wrong.
The managed way:
<br />
Bitmap bmp = null;<br />
System.IO.Stream imgStream = thisExe.GetManifestResourceStream( "Plugin.Resources.online_16x16.png" );<br />
<br />
bmp = Bitmap.FromStream( imgStream ) as Bitmap;<br />
if ( !( null == bmp ) )<br />
{<br />
Rectangle rect = new Rectangle( 0, 0, bmp.Width, bmp.Height );<br />
BitmapData bmpData = bmp.LockBits( rect, ImageLockMode.ReadOnly, bmp.PixelFormat );<br />
MediumEntry.png_image_16 = bmpData.Scan0;<br />
MediumEntry.png_image_16_len = (uint)imgStream.Length;<br />
<br />
bmp.UnlockBits( bmpData );<br />
}<br />
The C interop way:
<br />
IntPtr hMod = WinLoadApi.LoadLibraryEx(Pathtoatestdllwithpngimage, IntPtr.Zero, WinLoadApi.LOAD_LIBRARY_AS_DATAFILE);<br />
IntPtr hRes = WinLoadApi.FindResource(hMod, 209, "PNG");<br />
MediumEntry.png_image_16 = WinLoadApi.LoadResource(hMod, hRes);<br />
MediumEntry.png_image_16_len = WinLoadApi.SizeofResource(hMod, hRes);<br />
1) Should png_image_32/16 really be an IntPtr instead of String? I've tried both ways in code (actually the code above mostly uses IntPtr).
2) What am I missing, because I simply can't get ANY sort of image loaded from C# to show up in the C. app using its defined structure.
|
|
|
|
|
I am faced with a task of opening a provided comma delimited file which is in .csv., i.e I wish to open it in a spread sheet program. Any hints on the code format in C# . It has specific headers and will therefore end up with a list of workers having different values under each header. Many thanks.
|
|
|
|
|
If the spreadsheet is Excel, it will open a csv. Either way, how do you mean, to open it in C#, if you're opening it in an external program ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have opened the file using a C# program i have created. i am able to read the contents in a textbox using streamreader inputstream and openfile dialogue. But I wish to be able to read/access the contents in excel using my C# program.
|
|
|
|
|
OK - there's a library you can use to control Excel from C#, the Microsoft tools for office, or something ? Excel will just read yourcsv,but you can create workbooks in C#
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Any other suggestions,contributions? Not there yet.
|
|
|
|
|
Read my article on how to use google ?
http://www.google.com.au/search?sourceid=navclient&ie=UTF-8&rlz=1T4ADBS_enAU225AU226&q=C%23+Excel[^] is bursting with info.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Then you can't possibly want to do what you seem to be saying.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have this comma delimited file sent to me. I can open it in excel straightaway by downloading. But I am trying to understand how I can access it using my C# program codes. I have managed to open it quiet well in a textbox. Now since it already a comma delimited file I am trying to find a way of getting to it through my c# program and reading it as an excel thing using my c# program.
|
|
|
|
|
You wish to load the CSV file into your application with a grid view like in excel?
If so you need to read the CSV data into a dataset and then point that dataset to a data grid view control and it'll display just fine. To make changes and save them you'd need to serialize and convert the dataset back into CSV.
If you want to just open it in excel (if installed) you can just do the following:
string csvFilePath = "C:\myFile.csv";
using (Process MSexcel = new Process())
{
MSexcel.StartInfo.FileName = csvFilePath;
MSexcel.Start();
}
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
I have a data in a list, and l want to print to data form. How can l do this in C#. Thank you .
|
|
|
|
|
Is this an ASP.NET app ? I thought you were asking ASP.NET questions earlier ?
Use a datagrid. And buy a book, this is a very basic question.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for your response.
|
|
|
|
|
MessageBox.Show("Hellow")
it will print the hellow message in the popup messagebox.
or try Sytem.Console.Writeln("hellow");
|
|
|
|
|
Hi,
I am builting a server\client chat aplication.
One problem as appear to me when transfering data between server and client. I m not only trying to transfer messages data but also settings data, like for exemple the list(edit a listbox) of clients logged in!!!
I solved it in a not very elegant way:
1) server sends string data (01hello jack!!!),(04Boris),(09Boris),(02Hello Diana!)
2) client reads it with the help of the substring funtion (01:Private Message),(04:Login),(09:Logout),(02:Global Message)
I use it because i only send strind data?
Here´s my way of solving the problem!!!
Does anyone uses a different way?
|
|
|
|
|
Not me, personally.
String Manipulation (.Substring, .Replace) ftw!
-= Reelix =-
|
|
|
|
|
I'm trying to create an application that rotates an image based on the an angle created by your mouse from a certain point on the form.
I create a form, 500x500, and specify the point to get my angle from at (500,250). From that, everytime the mouse is moved, I grab the current x and y position of the mouse, and then using trig, try to find the angle from the point specified on the form to the mouse. However, I'm not sure if I'm approaching this correctly. Whenever I test my application, the image does rotate, however, it's very "hit-and-miss", and coincidentally, is even quite dodgy in some areas (it wont rotate in certain areas on the form). To rotate the image, I'm using matrices and I haven't had a problem rotating the image using a counter for the angle within a timer; but when I try to use mouse move... well you can only understand where I'm coming from.
Note: I commented out another method I thought off in order to prevent large jumps in the angles, however, it seems to do worse then the other method
private void Form1_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
try<br />
{<br />
<br />
rotationz = true;<br />
angle = (float)((Math.Atan((500 - e.Y) / (250 - e.X))) * (-180 / Math.PI));<br />
Invalidate();<br />
<br />
}<br />
catch (DivideByZeroException)<br />
{<br />
}<br />
}
I'm somewhat of a beginner, so if it is possible to keep it simplified/dumb downed so that it's easier for me to understand, it would be much appreciated! Thanks in advance
|
|
|
|
|
Does your paint code always rotate the original image, or does it rotate the already rotated image ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
it rotates the original image, not the rotated one, so i don't have to subtract the last angle from the current one. I got something working actually, but it's a bit ridiculous, perhaps anyone else could simplify my code?
try<br />
{<br />
<br />
if (e.X > 250 && e.X < lastx)<br />
{<br />
curangle = (int)((Math.Atan((500 - e.Y) / (250 - e.X))) * (-180 / Math.PI));<br />
}<br />
else if (e.X > 250 && e.X > lastx)<br />
{<br />
curangle = (int)((Math.Atan((500 - e.Y) / (250 - e.X))) * (180 / Math.PI));<br />
curangle = -180 - curangle;<br />
}<br />
if (e.X < 250 && e.X < lastx)<br />
{<br />
curangle = (int)((Math.Atan((500 - e.Y) / (250 - e.X))) * (180 / Math.PI));<br />
curangle = 180 - curangle;<br />
}<br />
else if (e.X < 250 && e.X > lastx)<br />
{<br />
curangle = (int)((Math.Atan((500 - e.Y) / (250 - e.X))) * (-180 / Math.PI));<br />
}<br />
<br />
}<br />
catch (DivideByZeroException)<br />
{
For some of those, you'll notice my curangle is touched upon once again within the if statements; I only did that in order to account for both positive and negative rotations left and right. It's kinda long though, so any suggestions would be great ! Thanks again for the help guys!
|
|
|
|
|