|
Nooner wrote: I would strongly recommend that you review the history of the video
I think you are asking too much of him, this guy can't even use Google so actually doing some research seems a little beyond him.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I just know there is one generics: ArraySegment, is used to take one part of an array.
but I really do not understand why this special generics is given (in contranst to other more general generics such as List<>, Dictionary<> and so on). because it seems to me it can only realize single function: take one part of an array.
therefore, is it necessary to define one generics ArraySegment? instead, one method can be added into Array or List is just fine.
Perhaps my understanding is not correct.
thanks
|
|
|
|
|
Huh, never heard of it, I wrote my own, I'll have to take a look at it.
I suspect that part of the reasoning for it is that the D language has array slicing built in.
|
|
|
|
|
I too had not looked at this before.
From a brief look, I think you are largely correct, although there is (very) slightly less typing involved in array slicing when using it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi, i wanna retrieve my blob data from mysql database..
After retrieving it, i wanna use the image on one of my button.
How do i do that? any clues?
|
|
|
|
|
Get the data as a byte array, load the array into a MemoryStream, use Image.FromStream() to read it as an image. Apart from the blob being a byte array, the method of retrieving the data is as usual. If you have a MySQL database driver installed on the computer, the DataGridView will automatically show the blob as an image
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I dont quite know how to do that, but this is the code i have
private void getMainCommImages()
{
Byte[] image = null;
MySqlDataReader reader = db.getMainCommImages();
while (reader.Read())
{
image = new Byte[(reader.GetBytes(0,0,null,0,int.MaxValue))];
reader.GetBytes(0, 0, image, 0, image.Length);
reader.Close();
db.Close();
}
}
public MySqlDataReader getMainCommImages()
{
Connect();
command = conn.CreateCommand();
command.CommandText = "SELECT image from images";
reader = command.ExecuteReader();
return reader;
}
after getting the image in bytes. how do i display out to my button
modified on Thursday, June 11, 2009 1:29 PM
|
|
|
|
|
So where does it fail? Do you get the correct byte array? If you do, then simply create a MemoryStream(byte[]) and use Image.FromStream
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thanks i got it working.
Btw, i have 15 buttons name btn1, btn2, btn3 etc etc
i have 15 images as well in my database. How do i get those images to be on each button.
private void getMainCommImages()
{
Byte[] image = null;
MySqlDataReader reader = db.getMainCommImages();
MemoryStream ms;
Image returnImage;
while (reader.Read())
{
image = new Byte[(reader.GetBytes(0,0,null,0,int.MaxValue))];
reader.GetBytes(0, 0, image, 0, image.Length);
ms = new MemoryStream(image);
returnImage = Image.FromStream(ms);
for (int i = 1; i < 15; i++)
{
btn[i].Image = returnImage;
}
}
reader.Close();
db.Close();
}
something wrong with this part btn[i].Image = returnImage;
|
|
|
|
|
Every button's image will be the last image read from the database. Try something like this:
private void getMainCommImages()
{
Byte[] image = null;
MySqlDataReader reader = db.getMainCommImages();
MemoryStream ms;
Image returnImage;
int i = 0;
while (reader.Read())
{
image = new Byte[(reader.GetBytes(0,0,null,0,int.MaxValue))];
reader.GetBytes(0, 0, image, 0, image.Length);
ms = new MemoryStream(image);
returnImage = Image.FromStream(ms);
foreach(Control ctrl in this.Controls)
{
if(ctrl.Name == "btn" + i.ToString())
{
ctrl.Image = returnImage;
break;
}
}
i++;
}
reader.Close();
db.Close();
}
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
i got this error
Error 1 'System.Windows.Forms.Control' does not contain a definition for 'Image' and no extension method 'Image' accepting a first argument of type 'System.Windows.Forms.Control' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Fossil\Desktop\IITSC_App\IITSC_App\IITSC_App\IITSC_App\frmMain.cs 104 30 IITSC_App
|
|
|
|
|
its ok. I got it working
Thanks for your help..
This is my solution
private void getMainCommImages()
{
Byte[] image = null;
MySqlDataReader reader = db.getMainCommImages();
MemoryStream ms;
Image returnImage;
int i = 1;
while (reader.Read())
{
image = new Byte[(reader.GetBytes(0,0,null,0,int.MaxValue))];
reader.GetBytes(0, 0, image, 0, image.Length);
ms = new MemoryStream(image);
returnImage = Image.FromStream(ms);
foreach (Control ctrl in tabPage3.Controls)
{
if (ctrl is Button)
{
if (ctrl.Name == "btn" + i.ToString())
{
((Button)ctrl).Image = returnImage;
break;
}
}
}
i++;
}
reader.Close();
db.Close();
}
|
|
|
|
|
I am looking at a series of header files with thousands of #define statements in them. I have been tasked with writing a utility that utilizes these defines in C#. I know that I can manually convert these, but unfortunately they are living files and I would have a maintenance nightmare.
My question is does anyone have or used any utilities that can be run has a pre-build process from inside VS that converts header file #define to C# constant?
Any help on this is greatly appreciated!
~Mike
|
|
|
|
|
You can use the utility MSBuild Task[^] that provides the code that runs during the build process.
You need to include the code to convert header file #define to C# constant
|
|
|
|
|
I use the C pre-processor and then pass the result to CSC. But I don't know about integrating that with VS.
One of the problems with trying to automatically convert it is that the macroes don't specify a type.
Another solution would be to store the items in XML and then use XSLT to produce either C/C++ (h) or C# code as required.
|
|
|
|
|
Interesting idea...I have a question as to what and how you pass data from the C pre-processor to the CSC?
Thanks everyone for you thoughts!
|
|
|
|
|
"C:\mingw\bin\cpp" -P -C -w %1.cs %1.csi
csc.exe @"C:\batfiles\Build.rsp" %1.csi
|
|
|
|
|
Thanks PIEBALDconsult...Couple questions
1. Is this entered at the command-line or via a batch file?
2. The "C:\mingw\bin\cpp" reference. Where is this from?
Thanks again!
|
|
|
|
|
Those are part of my CC.BAT file.
http://www.mingw.org/[^]
I'm trying to remember where I got the installer I used, at the moment I can't even find the file I downloaded.
Ah, I remember; at one point I had installed Quincy[^] and it installed MinGW.
When I built my current system I simply copied the directory tree over.
modified on Thursday, June 11, 2009 2:58 PM
|
|
|
|
|
Thanks..I will look into this
|
|
|
|
|
Yeah, tricky. Interesting problem too. I guess you're right, have a prebuild step which parses the #defines and spits out constant integers. I know of no such tool, but should be easy to write yourself.
I've got some vague recollection that .NET doesn't stash constant integers in metadata but resolves them to numbers during main compilation. If this is correct, if your constants are used outside the assembly they're defined in, you'd need to rebuild that assembly as well. Just replacing the one assembly don't work. Perhaps someone here could confirm that or tell me I dreamt it.
Regards,
Rob Philpott.
|
|
|
|
|
I have the following scenario. I have a WinForm that has a TableLayoutPanel in which each cell has a GroupBox that is logically separating the controls on the form. Now, each group box has a button which can be considered the default button if and only if Enter is pressed in one of the textboxes in that group box in that particular cell in the table layout panel.
Now, the default button is no longer an option and I assume that that is because of the table layout panel, so the idea of having one massive select statement figure out which "default" button to fire won't work.
Is there a proper way of doing this?
If the post was helpful, please vote!
Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ
Now and forever, defiant to the end.
What is Multiple Sclerosis[ ^]?
|
|
|
|
|
Are all the GroupBoxes identical? If so, then what about a custom control, derived from GroupBox, which has the controls already added. Perhaps adding a property to expose the Button and TextBox for flexibility. When the return key is pressed in the TextBox, use the PerformClick() method of the Button. Then, just add the derived GroupBox control to the TableLayoutPanel in place of the normal GroupBox setup
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Computafreak wrote: Are all the GroupBoxes identical?
In what sense? Their contents represent different things, for example, Name in Arabic, Name in English, National ID Number etc. If you mean functionality wise, what is happening right now is that each Group Box has its own button that then grabs the info from the right text box and grabs all the information from the DB that matches that criteria. Some stuff are not unique (nationality for example) and so will return a number of matches.
I like the idea, but I don't know if its applicable in my case.
Thanks though
If the post was helpful, please vote!
Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ
Now and forever, defiant to the end.
What is Multiple Sclerosis[ ^]?
|
|
|
|
|
DefaultButton may not be available, but AcceptButton still is, because that's what it is called in C# WinForms!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|