|
Hello
1- Write your image so a stream of bytes using Image.Save(Stream, ImageFormat) method.
2- Write that array of bytes to your database.
3- When reading the image from the file reverse the process and use Image.FromStream(Stream) to read the stream into the image object.
4- Use the PictureBox.Image property to display your image.
Regards
|
|
|
|
|
This question has been asked and answered many, many times. I suggest you search the forum.
|
|
|
|
|
Hi,
I have a web site with:
A MasterPageDefault and
Page1 and Page2, which both referes to MasterPageDefault.
On MasterPageDefault I have put a delete button. Now in the codebehind file, I want to delete two diferent things which depends on what page I stand on. Therefore I need to know, which page I stand on.
Is there anyone, who can help me, to find some code, which kan determe on which page I stand on?
Kind regards,
simsen
|
|
|
|
|
What framework variable do I use to access the path to My Documents?
|
|
|
|
|
My Documents is a "special folder" and is accessed using the Shell. So however the framework exposes the Shell that is how you get the solution.
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
That is not an answer to my question.
|
|
|
|
|
They hide the rest of the information in the Documentation[^]
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
Hello
string MyPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
Regards
|
|
|
|
|
The Documentation says it works with 1.1 but I'm not seeing the enum SpecialFolder.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
Hello
Why don't you see it in your intellisense?? It should appear. Try writing without the intellisense. What compile error -if any- appears?
Piece of advice:
Remove you email address to avoid the possibility of spamming.
Regards
|
|
|
|
|
I have a class
public class myclass : BindingList<T> {}
I have created(shadowed) the GetEnumerator method to provide some custom sorting and what not.
But the problem is the type can be Category, Topic, or Entry.
And I need to test each one because each has its own sorting strategy.
I tried if( typeof(T) is Category) but that doesn't work.
What is the easiest way to determine the type T is?
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
typeof(T) will always return a type of T, and T is really a type identifier. What you may try is this:
public void Sort(T item)
{
if ( item is Category )...
if ( item is Volume ) ...
}
|
|
|
|
|
lol. its a GetEnumerator(). Theres no definition like that.
<br />
Type t = typeof(T);<br />
<br />
if( t.Equals(Category) )<br />
<br />
I figured it out just a second ago
Thanks tho
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Hi,
In my Win form, I have a variable name string myVar.
Ok, now I want to bind this varibale to a binding source same like a control's certain property is bound to a member of a data binding source.
Right now, In order to do this, I placed a hidden text box bound to a data binding source (text property) and created an event handler for TEXT CHANGED event and on text change, I update the value of the variable with the content of that hidden text box.
Now, How can I avoid this hidden text box and directly bind the variable with a certain member of a data binding source.
Thanks in advance.
Regards,
|
|
|
|
|
You can do the same thing by creating a datatable, add a column named something with a typeof(string) and your data becomes bound to a "datasource".
For example: I'm adding a datasource for my checkboxes so that sorts keep the state of the checkbox.
....
batchSelectColumn = new DataGridViewCheckBoxColumn();
batchSelectColumn.Width = 30;
batchSelectColumn.DisplayIndex = 0;
batchSelectColumn.Name = "BatchSelectColumn";
batchSelectColumn.ThreeState = false;
batchSelectColumn.DataPropertyName = "SelectColumn";
batchSelectColumn.HeaderText = string.Empty;
viewer.BatchGrid.Columns.Add( batchSelectColumn );
DataTable BATCHHEADER = new DataTable();
BATCHHEADER.Columns.Add( "SelectColumn", typeof(bool) );
|
|
|
|
|
Hi,
Thanks for your reply.
As I always make same table columns in dataset as available in real SQL database. Because, I did not learn if I have extra column in my dataset which is really not in SQL, then How can I reflect the changes of that DataTable to the original SQL database.
Now, would you please help me to with an idea, how can I access the bounded column’s value directly from my code ? In order to explain my question, please allow me to give you an example.
In the property editor of a Textbox, there is a property for databinding. In that property editor, I can use visual editor to set the text property of the text box to a bounded data column of the datasource (Selecting a NODE from the DataSource Table – Column Tree).
Now, how can I GET or SET value to that data column directly using variable from programming code ? By doing that, when the binding navigator will be used to navigate data row by row, I will be able to show a calculated value to a control from a particular data column’s value.
Thanks a lot in advance as I asked a long question.
|
|
|
|
|
is there a way to cancel a foreach loop before it has iterated through the entire collection, without throwing an exception?
i have a loop that feeds a string to a switch() and i want it to terminate if a certain parameter is fed to it.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
|
when iterating through a collection, there are several ways that you can exit the for loop. Mostly it depends on the logic in your program.
foreach ( Element item in elements )
{
...
if ( item == condition ) break;
}
more logic
foreach ( Element item in elements )
{
...
if ( item == failure ) return;
if ( item == typeof(Bypass) continue;
... more logic ...
if ( item.State == State.NoPostProcessNeeded )
break;
post process logic ...
}
epilogue logic
return;
|
|
|
|
|
Hi,
I am following this appbar tutorial http://www.codeproject.com/Purgatory/AppBar.asp . I can get the form to occupy a section of the desktop area but when I end the application the space isn't given back to other applications. Does anyone know what I am doing wrong and how I can stop this from happening?
My code is:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace WindowsApplication2
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(88, 32);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(112, 64);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Closing += new System.ComponentModel.CancelEventHandler(this.OnClosing);
this.Load += new System.EventHandler(this.OnLoad);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private System.Windows.Forms.Button button1;
#region APPBAR
[StructLayout(LayoutKind.Sequential)]
struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[StructLayout(LayoutKind.Sequential)]
struct APPBARDATA
{
public int cbSize;
public IntPtr hWnd;
public int uCallbackMessage;
public int uEdge;
public RECT rc;
public IntPtr lParam;
}
enum ABMsg : int
{
ABM_NEW=0,
ABM_REMOVE=1,
ABM_QUERYPOS=2,
ABM_SETPOS=3,
ABM_GETSTATE=4,
ABM_GETTASKBARPOS=5,
ABM_ACTIVATE=6,
ABM_GETAUTOHIDEBAR=7,
ABM_SETAUTOHIDEBAR=8,
ABM_WINDOWPOSCHANGED=9,
ABM_SETSTATE=10
}
enum ABNotify : int
{
ABN_STATECHANGE=0,
ABN_POSCHANGED,
ABN_FULLSCREENAPP,
ABN_WINDOWARRANGE
}
enum ABEdge : int
{
ABE_LEFT=0,
ABE_TOP,
ABE_RIGHT,
ABE_BOTTOM
}
private bool fBarRegistered = false;
[DllImport("SHELL32", CallingConvention=CallingConvention.StdCall)]
static extern uint SHAppBarMessage(int dwMessage, ref APPBARDATA pData);
[DllImport("USER32")]
static extern int GetSystemMetrics(int Index);
[DllImport("User32.dll", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, bool repaint);
[DllImport("User32.dll", CharSet=CharSet.Auto)]
private static extern int RegisterWindowMessage(string msg);
private int uCallBack;
private void RegisterBar()
{
APPBARDATA abd = new APPBARDATA();
abd.cbSize = Marshal.SizeOf(abd);
abd.hWnd = this.Handle;
if (!fBarRegistered)
{
uCallBack = RegisterWindowMessage("AppBarMessage");
abd.uCallbackMessage = uCallBack;
uint ret = SHAppBarMessage((int)ABMsg.ABM_NEW, ref abd);
fBarRegistered = true;
ABSetPos();
}
else
{
SHAppBarMessage((int)ABMsg.ABM_REMOVE, ref abd);
fBarRegistered = false;
}
}
private void ABSetPos()
{
APPBARDATA abd = new APPBARDATA();
abd.cbSize = Marshal.SizeOf(abd);
abd.hWnd = this.Handle;
abd.uEdge = (int)ABEdge.ABE_TOP;
if (abd.uEdge == (int)ABEdge.ABE_LEFT || abd.uEdge == (int)ABEdge.ABE_RIGHT)
{
abd.rc.top = 0;
abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height;
if (abd.uEdge == (int)ABEdge.ABE_LEFT)
{
abd.rc.left = 0;
abd.rc.right = Size.Width;
}
else
{
abd.rc.right = SystemInformation.PrimaryMonitorSize.Width;
abd.rc.left = abd.rc.right - Size.Width;
}
}
else
{
abd.rc.left = 0;
abd.rc.right = SystemInformation.PrimaryMonitorSize.Width;
if (abd.uEdge == (int)ABEdge.ABE_TOP)
{
abd.rc.top = 0;
abd.rc.bottom = Size.Height;
}
else
{
abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height;
abd.rc.top = abd.rc.bottom - Size.Height;
}
}
// Query the system for an approved size and position.
SHAppBarMessage((int)ABMsg.ABM_QUERYPOS, ref abd);
// Adjust the rectangle, depending on the edge to which the
// appbar is anchored.
switch (abd.uEdge)
{
case (int)ABEdge.ABE_LEFT:
abd.rc.right = abd.rc.left + Size.Width;
break;
case (int)ABEdge.ABE_RIGHT:
abd.rc.left= abd.rc.right - Size.Width;
break;
case (int)ABEdge.ABE_TOP:
abd.rc.bottom = abd.rc.top + Size.Height;
break;
case (int)ABEdge.ABE_BOTTOM:
abd.rc.top = abd.rc.bottom - Size.Height;
break;
}
// Pass the final bounding rectangle to the system.
SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref abd);
// Move and size the appbar so that it conforms to the
// bounding rectangle passed to the system.
MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, true);
}
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == uCallBack)
{
switch(m.WParam.ToInt32())
{
case (int)ABNotify.ABN_POSCHANGED:
ABSetPos();
break;
}
}
base.WndProc(ref m);
}
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style &= (~0x00C00000); // WS_CAPTION
cp.Style &= (~0x00800000); // WS_BORDER
cp.ExStyle = 0x00000080 | 0x00000008; // WS_EX_TOOLWINDOW | WS_EX_TOPMOST
return cp;
}
}
#endregion
private void OnLoad(object sender, System.EventArgs e)
{
RegisterBar();
}
private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
RegisterBar();
}
private void button1_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}
Many thanks for your time and help.
Al
|
|
|
|
|
Muller2 wrote: but when I end the application the space isn't given back to other applications.
You mean this[^]
"Oh and for everyone who tried the code and wonder how to close it, click on it to get the focus on it and hit Alt-F4 (if you hit stop you're stuck with a unaccesible area on your desktop)"
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
Yes that works but I want to know how to terminate the program by clicking a button without telling the user to press Alt+F4.
Is there anyother solution to closing this app?
|
|
|
|
|
Muller2 wrote: Is there anyother solution to closing this app?
I don't see that issue being addressed in the article so... not a known one, no.
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
Should be quite simple: If you look at the code you'll see that an event handler for Closing is being attached which is calling RegisterBar() .
So you simply can add a button that's calling this.Close(); and you should be fine.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hello
I hope Led gave you a good enough answer. I just wanted to nudge you about the code you posted. Posting a 9,223,372,036,854,775,807 pixels long code will surely discourage anyone from reading it!! Specially if you didn't enclose it with pre tags. You should only post the code that you suspect that is causing the problem. To get to this use break points, stepwise debugging, tracing, guessing, commenting/decommenting, or any other method that suits you. Just post as little code as you can.
Regards
|
|
|
|
|