|
Thats's not the problem as far as I can see - sorry I'm struggling a bit with your english to understand what you are saying, but I think your issue is that the connection is fine - it's what you are trying to do with it is wrong. You can't use an INSERT (SQL) statement as a SelectCommand on the adapter and you can't use the Fill method on the adapter to call the InsertCommand - you have to use the Update method instead.
Perhaps you can put up the error and maybe that might cast some more light - but it looks as though it's just an issue with using the adapter incorrectly...
|
|
|
|
|
i tryed "select * from image" and they don't work
and i tryed "select * from patients" and they work
and the two table are in the same file named data_base.mdb
thanks anyway
|
|
|
|
|
Hmmm ok that is strange,
One thing that can occue on a SQL database is that case sensitivity can be on which means that a table called Image will not be found if you look for a table called image - no idea if that applies to an access database - but I guess it's worth a try?
|
|
|
|
|
Hi everyone,
I'm running into a problem while trying to format strings for printing. I'm working heavily with finance and I need the values to be flushed right and formatted as cash. Unfortunately none of the values are being formatted correctly. I assumed that if the String.Format() function was used correctly that the string would be returned with all the information needed to line it up correctly. I ran into a similar problem when trying to line up information in combo boxes. What I think is going on is that the width of a space is much smaller then the width of the characters in a font. Does anyone know of a workaround for this? Thanks. - Will
|
|
|
|
|
Sure, the easy way out is to display/print (parts of) the text using a so called
"non-proportional" font; such font has all characters (including the space char)
with the same width. An example is "Courier New".
|
|
|
|
|
Thanks Luc, That did the trick. I was trying to use system before because I thought it was lined up, but courier worked beautifully.
|
|
|
|
|
I made a C# application and i want the Textbox control to just take numbers and no characters. In VC++ this can be easily done by setting a property.
Any idea how to do this in C#?
Thanks
|
|
|
|
|
Handle the keypress event and check input
|
|
|
|
|
this is easy thing.
you can set as
:
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if ( !( char.IsDigit( e.KeyChar ) ) )
{
e.Handled = true;
}
}
roger wong
msn:wenmianbj@hotmail.com
|
|
|
|
|
The method you suggested works. Thanks.
One problem now is that the "Backspace" button no more works inside the text box.
Any idea why thats happening?
"Delete" button works.
|
|
|
|
|
U can use Regular Expression Validation control.
Validation Control will not allow other characters except numbers by setting the expression as ^[0-9]+$ in validation control
|
|
|
|
|
I was thinking about instead of having a normal boring form I wanted to make a custom UI but I am blanking on how to get a UI to work. I want to make it that there are tabs, or what not and if they click on it then it will animate it as it opens.
http://www.marcmercuri.com/content/binary/InfoCenter_Old.JPG
That is just an example...
I have done alot of this in Flash but in C# I have no idea where to start. Would I have to make the tab that I want to open a sprite? An animated GIF? I searched for quite a while and found tutorials using GDI+ and graphics but almost all describe making a small animated guy move across the screen. What I want to do is have the tab that is clicked to grow across the screen and then it will show more options. If it is clicked again it shrinks back into the tab on the side.
Any ideas or links to where I might look to find something like this would be great.
Thank you,
Rob
|
|
|
|
|
Ok, I got this working. I just used a sliding graphic and it works quite well. I just made the graphic slide in when clicked then auto go back. Making it stop and go back when clicked again is easy enough to add in. I am not sure how this will behave when I stick more then one slider on top of each other but it should be fine.
This is the bar graphic I am using.. http://themcclellanfamily.com/Bar.bmp (put this in your debug folder for the project)
This is the code I am using in case anyone wants to see or tweak it. It is nothing special, it is just a scrolling graphic but my plan is to make the tabs huge, someone clicks on it, it opens, loads in the controls, buttons, etc for that topic for that tab. They click on the open tab and it will remove the controls then close itself. Adding the controls dynamically is easy, this is what was giving me issues. Anywho...here is the code
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace sliding
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Timer t;
private System.Drawing.Size playerSize;
private System.Drawing.Point playerPosition;
bool back = false;
bool goFull = false;
bool stopMove = true;
int mouseX=0;
Image pic;
public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
pic = Image.FromFile("Bar.bmp");
t = new Timer();
t.Interval = 40;
t.Tick += new System.EventHandler(TimerOnTick);
t.Enabled = true;
playerSize = new Size(540, 20);
playerPosition = new Point(-300, 20);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Form1MouseClick);
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(640, 480);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.Name = "Form1";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Form1";
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1MouseClick);
this.ResumeLayout(false);
}
private void TimerOnTick(object sender, System.EventArgs e)
{
if (this.PlayerPosition.X >-20)
{back = true;
goFull= false;
}
if (this.PlayerPosition.X < -300 && back==true)
{
goFull = false;
back = false;
stopMove= true;
}
if (!stopMove && back==false)
{this.PlayerPosition = new Point(this.PlayerPosition.X
+ 15,
this.PlayerPosition.Y);
goFull = true;
}
else if (!stopMove && back==true)
{this.PlayerPosition = new Point(this.PlayerPosition.X
- 15,
this.PlayerPosition.Y);
goFull = true;
}
this.Refresh();
this.Text = " " + this.PlayerPosition.ToString() + " "+mouseX+" "+stopMove;
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
Graphics dc = e.Graphics;
dc.DrawImageUnscaled(pic, this.PlayerPosition);
base.OnPaint(e);
}
private Point PlayerPosition
{
get
{
return this.playerPosition;
}
set
{
this.playerPosition.X = value.X;
this.playerPosition.Y = value.Y;
}
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
void Form1MouseClick(object sender, MouseEventArgs e)
{
mouseX = e.X;
this.Text = Convert.ToString(e.X);
if (e.X < playerPosition.X + playerSize.Width && e.X > playerPosition.X && !stopMove &&goFull==false )
{
stopMove = true;
goFull = true;
}
else if (e.X < playerPosition.X + playerSize.Width && e.X > playerPosition.X && stopMove &&goFull==false)
{
goFull = true;
stopMove = false;
}
}
}
}
|
|
|
|
|
I am working on a project that needs to incorporate a C DLL. It is more like a wrapper to the DLL for C# developers. I have done some reading about unmanaged code in C#, importing a DLL and functions with the dllimport attribute. However I have not seen anything that is related to my situation.
The DLL has its own types, lets assume a connection (cxn) and a file (fh). Now I need to be able to use instances of those in C#. For example:
In C/C++ id just declare a new object
<br />
Cxn my_cxn; <br />
....<br />
Then I could go on and use that as a parameter to other functions.
How do I do this in C#?
Also, I think I am on track for strings. All of the functions in the DLL use LPCWSTR strings. So I am using the MarshalAS attribute to specify this. Example:
<br />
[DllImport("mylib.dll", CharSet=CharSet.Unicode)]<br />
static extern int CxnOpen([MarshalAs(UnmanagedType.LPWStr)] string smtp,<br />
[MarshalAs(UnmanagedType.LPWStr)] string http,<br />
[MarshalAs(UnmanagedType.LPWStr)] string dom,<br />
[MarshalAs(UnmanagedType.LPWStr)] string rep,<br />
IntPtr temp);<br />
|
|
|
|
|
Newbie quests...
How do you compile with the /unsafe option from VS2005? Also, GetHashCode returns a generated HashCode for a variable. Conversely, how do you return the original value from the code created?
Jon
|
|
|
|
|
Hi!
1. Right click on the project in the solution and open its properties. Its a checkbox on the second tab.
2. You cannot create an object from a hash code. It is not unique. Several distinct values may generate the same hash code, although code hash code algorithms have a very low chance for this to happen.
Robert
|
|
|
|
|
I am adapting TCartwright's Modal popup to use with a current project, however when I click on the Edit button, nothing happens. It just reposts with the gridview and no popup. How can I fix this? I have looked at both of our codes and don't see anything out of whack, but I am no expert at this.
This modal popup was used in TCartwright's Article.
Does anyone know why the popup would not display after clicking the edit button? I know it is probably something small that I haven't thought of.
This is the first time I have used Ajax so am at a loss in fixing it.
~Candi
|
|
|
|
|
First, if you are having problems with code from an article you should contact the author.
Second, make sure there are no popup blockers interfering with the operation.
only two letters away from being an asset
|
|
|
|
|
Thanks Mark!
I have posted this same question to the article. I was not sure if I should post it to the forums or the article. Thanks again!
~Candi
|
|
|
|
|
I have been working with a solution to this problem for a while but have not found a good solution. From a web page, you choose how many rows of text you want to display on an image. You can choose different fonts, sizes and font styles as well.
I have not found a really good solution to get the exact string width and height. Measurestring dosent work. Has anyone created a working solution for this?
Kindly regards,
Robert Johansson
|
|
|
|
|
MeasureString doesn't work? How so?
only two letters away from being an asset
|
|
|
|
|
Measurestring has problems with getting the correct size if you are using different font styles and fonts.
|
|
|
|
|
Hi,
I am quite satisfied with Graphics.MeasureString
it seems to predict well the size that will be required by Graphics.DrawString
provided you offer both methods basically the same working conditions.
I am confused about your "different font styles and fonts", both methods expect
a single font. If you want to concatenate text fragments in different fonts,
that is up to you, both for MeasureString and for DrawString.
|
|
|
|
|
There's MeasureCharacterRanges but it's a pain, buggy, and slow. I wrote a textbox control from scratch, and used the GetCharacterPlacement[^] GDI API. For your convenience:
[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern int GetCharacterPlacementW(IntPtr dev, string text, int count,
int max, [In, Out] ref GCP_RESULTS results, GcpFlags flags);
[Flags]
internal enum GcpFlags
{
DBCS = 0x00000001,
ReOrder = 0x00000002,
UseKerning = 0x00000008,
GlyphShape = 0x00000010,
Ligate = 0x00000020,
Diacritic = 0x00000100,
Kashida = 0x00000400,
Error = 0x00008000,
Justify = 0x00010000,
FliGlyphs = 0x00040000,
ClassIn = 0x00080000,
MaxExtent = 0x00100000,
JustifyIn = 0x00200000,
DisplayZWG = 0x00400000,
SymSwapOff = 0x00800000,
NumericOverride = 0x01000000,
NeutralOverride = 0x02000000,
NumericsLatin = 0x04000000,
NumericsLocal = 0x08000000,
FliMask = 0x0000103B
}
[StructLayout(LayoutKind.Sequential)]
internal struct GCP_RESULTS
{
internal int lStructSize;
[MarshalAs(UnmanagedType.LPTStr)]
internal string lpOutString;
internal IntPtr lpOrder;
internal IntPtr lpDx;
internal IntPtr lpCaretPos;
internal IntPtr lpClass;
internal IntPtr lpGlyphs;
internal int nGlyphs;
internal int nMaxFit;
}
[EDIT: Oh, duh - I forgot: I used a hack that allowed me to use DrawDriverString() GDI+ function to draw the text in the resulting character positions, even though it is not made available in System.Drawing . This is sounding more like material for a whole article, not a single post... hmm. More on this when I get a chance...]
--Justin
Microsoft MVP, C# v>
|
|
|
|
|
Hello,
I hope one of you have found a solution to the following problem before. . . Thanks in advance if you have.
I'm receiving events from an external dll (an RTDServer - set up like an observer pattern), and i've a Notify method that's called when there's an update to be collected. I can then collect a System.Array with a list of updates on a separate thread.
The problem is that the list will contain a number of different update types, and i've to set different variables in an object based on the differentupdates andI've to handle that list (one by one). Which of the following are possible/advisable, and can anyone recommend a better approach?
(a) use a hashtable/sortedlist/sorteddictionary with an indexer and the names of some variables in an object. Search the list, set the object variable, and let the object call any other events needed in the get/set method.
(b) write some kind of custom enumerator for the event types or variables to be set.
(c) use a hashtable/sortedlist/sorteddictionary with an indexer an objects of type Event. Just search the list for the indexer, and call the event to subscribers.
(d) some combination of the above.
The only thing is that speed is very important, because I migt have to call these events sequentially - I haven't investigated doing a foreach on the invocation list and calling asynchronously.Although they're small, I'll have possibly a hundred of these objects, with a hundred threads collecting updates.
Any help with this problem would be much appreciated.
Thanks,
Tom.
|
|
|
|