|
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.”
|
|
|
|
|
Nope. Its available on the form itself but not from any of the other controls (group boxes in particular), but I remember toying with it before I went to Lebanon and it didn't do what I wanted it to. Giving it another try..
Confirmed, the form is not capturing the Enter keypress. I'm guessing that the event is not bubbled up from the textbox.
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[ ^]?
|
|
|
|
|
The only reference to DefaultButton I could find on my local MSDN gave results in the System.Web.UI namespace.
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.”
|
|
|
|
|
Yeah, I'm jumping between paradigms! That does bad stuff to the stuff between my ears!
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[ ^]?
|
|
|
|
|
By exposing the Button, TextBox and Label, you could make changes to them - with a bit of designer hodge-podge, and a few PropertyGrid attributes you might be able to get that code into the Designer.cs files, where it would normally be. If the controls are exposed, you can hook the events as usual. It would probably be immensely boring to add the controls manually, but IMO it'd look better than one humongous switch statement. You could also try putting the name of the Button which should be clicked in the Tag property of the TextBox and having a common KeyPress handler for every TextBox which reads the Tag, searches for a Button with that name in the Parent's Controls collection, and clicks it
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Ugh! Massive Switch Statement
Computafreak wrote: By exposing the Button, TextBox and Label, you could make changes to them - with a bit of designer hodge-podge, and a few PropertyGrid attributes you might be able to get that code into the Designer.cs files, where it would normally be.
Wouldn't that require a new control for each group box? It might be worth it in the future, but for now I'll stick to the multiple button solution.
Thanks buddy!
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[ ^]?
|
|
|
|
|
Mustafa Ismail Mustafa wrote: Wouldn't that require a new control for each group box?
Yes, but the way I see it, you'd be creating a new control for each new GroupBox anyway. Unless you mean a new derived control, in which case no - you'd simply need to change the properties as usual
Mustafa Ismail Mustafa wrote: Thanks buddy!
You're welcome
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
More of a philosphical question - why do you need multiple default buttons? The Accept button dismisses the dialog box, so how does it matter which button click causes it to go away?
|
|
|
|
|
hi can any one help me how to do xp sidebar in ms.net2005 using c#
|
|
|
|
|
Lots of them already coded for you
safe=[^]
|
|
|
|