|
I set stream.Position = 0.
Unfortunately, I still get the same ArgumentException.
Thanks in advance
|
|
|
|
|
A little searching finds that you should pass your byte array "pictureData" to the constructor for the MemoryStream. Then pass the stream to the Bitmap constructor.
byte[] pictureData = <<...Ole Object...>>
Stream stream = new MemoryStream(pictureData, 0, pictureData.length);
Bitmap bitmap = new Bitmap(stream);
Resource: http://www.csharphelp.com/board2/read.html?f=1&i=40858&t=40858
Just because we can; does not mean we should.
|
|
|
|
|
I tried your code but I still get the same problem.
Thanks in advance
|
|
|
|
|
i have a number in my table that i need to inser in the database.the loop is returning a null value.how to convert object to string .here is my code.
can anyone help on this..
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OracleClient;
/// <summary>
/// Summary description for TMPerminent
/// </summary>
public class TMPerminent
{
#region Variables
OracleConnection con;
#endregion
#region CONNECTION STRING
public string connectionString = System.Configuration.ConfigurationManager.AppSettings["OracleConnectionString2"];
# endregion
public TMPerminent()
{
OracleConnection con = new OracleConnection(connectionString);
}
//public void AddNewRow(DataRow gvWeekDays,DataRow gvHrsNewRow, DataRow gvTaskNewRow, string strTWODID,string strEmpTSID)
public void AddNewRow(string dayid, string dayhrs, ref DataRow gvTaskNewRow, string strTWODID, string strEmpTSID)
{
//string strDay = null;
//string strHrs = null;
//Get the values stored in the text boxes
string txtDivision = gvTaskNewRow[0].ToString();
string txtSegment = gvTaskNewRow[1].ToString();
string txtDetail = "0";//gvTaskNewRow[2].ToString();
string txtFuntion = "0";//gvTaskNewRow[3].ToString();
string txtDescription = "0";//gvTaskNewRow[4].ToString();
string txtTask = "0";//gvTaskNewRow[5].ToString();
string txtCounty = "0";//gvTaskNewRow[6].ToString();
string txtHighway = "0";//gvTaskNewRow[7].ToString();
//Get the values stored in the text boxes
txtDivision = gvTaskNewRow[0].ToString();
txtSegment = gvTaskNewRow[1].ToString();
txtDetail = gvTaskNewRow[2].ToString();
txtFuntion = gvTaskNewRow[3].ToString();
txtDescription = gvTaskNewRow[4].ToString();
txtTask = gvTaskNewRow[5].ToString();
txtCounty = gvTaskNewRow[6].ToString();
txtHighway = gvTaskNewRow[7].ToString();
//Prepare the insert Command of the DataSource control (inserting new record into the TASK TABLE)
string strInsertTask = "";
strInsertTask = "insert into TASK_WRK_ORDR_DTL (TXDOT_DIST_NBR,SGMNT_ID,DTL_CD,FUNC_CD,TASK_WRK_ORDR_CD,TXDOT_CNTY_NBR,HWY_CD,MISC_DSCR_TXT) values (" +
txtDivision + "," + txtSegment + "," + txtDetail + "," + txtFuntion + "," + txtTask + "," + txtCounty +
"," + txtHighway + "," + txtDescription + ")";
////Select the hrs data in the row
//for(int i=0 ; i < 7 ; i++ )
//{
// if (gvHrsNewRow[i].ToString() != string.Empty)
// {
// strHrs = gvHrsNewRow[i].ToString();
// strDay = gvWeekDays[i].ToString();
// break;
// }
//}
//prepare the insert command for the HRS table
string strInsertHrs = "";
//dayhrs = "123";
//dayid = "12";
strInsertHrs = "insert into TS_DAILY_ACTV (DAY_ID,TWOD_ID,EMP_TMSHT_ID,WRK_HRS_QTY) values (" + dayid + "," + strTWODID + "," + strEmpTSID + "," + dayhrs + ")";
//OracleConnection con = new OracleConnection(connectionstring);
OracleCommand cmdInsertTask = new OracleCommand(strInsertTask,con);
OracleCommand cmdInsertHrs = new OracleCommand(strInsertHrs,con);
con.Open();
cmdInsertTask.ExecuteNonQuery();
cmdInsertHrs.ExecuteNonQuery();
con.Close();
|
|
|
|
|
joynee wrote: strInsertTask = "insert into TASK_WRK_ORDR_DTL (TXDOT_DIST_NBR,SGMNT_ID,DTL_CD,FUNC_CD,TASK_WRK_ORDR_CD,TXDOT_CNTY_NBR,HWY_CD,MISC_DSCR_TXT) values (" +
txtDivision + "," + txtSegment + "," + txtDetail + "," + txtFuntion + "," + txtTask + "," + txtCounty +
"," + txtHighway + "," + txtDescription + ")";
Ah yes, string concatenation. Could someone please tell me what year it is? I'm sure I must have the wrong calendar.
Dear joynee, you might want to do some research on something called "SQL injection".
|
|
|
|
|
|
Well in 2008 if someone suggests you research something the obvious thing to do is type it into the Google keyword search input and click the search button. Then you attempt to locate a result that seems to provide a description of the item and read it.
However I can see how that might seem counter intuitive to posting a question in a forum, wait, no actually I can't.
|
|
|
|
|
|
Hi
i found in your code , this code snippet
//Get the values stored in the text boxes
txtDivision = gvTaskNewRow[0].ToString();
txtSegment = gvTaskNewRow[1].ToString();
txtDetail = gvTaskNewRow[2].ToString();
txtFuntion = gvTaskNewRow[3].ToString();
txtDescription = gvTaskNewRow[4].ToString();
txtTask = gvTaskNewRow[5].ToString();
txtCounty = gvTaskNewRow[6].ToString();
txtHighway = gvTaskNewRow[7].ToString();
please check is it correct?
i think that should be like this
//Get the values stored in the text boxes
txtDivision.Text = gvTaskNewRow[0].ToString();
---
thanks
|
|
|
|
|
No, his code is correct. You don't need to set the .Text property on a string. He prefixed the variables like it was a text box, but they were actually strings.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hey guys
im trying to hide an image object (blob field) on a crystal report at runtime. the user will check a checkbox to either display or hide the object.
ive been battling with this for days...
i added a formula to the report in the designer as "False" so if i dont change this property at runtime is shouldnt show at runtime? correct? i assign the formula to the blob object.
what ive done in the code is i get the formulas collection object from the report then instantiate a formula field from this collection. i then assign formulaField.Text = checkbox.checked.ToString()
but the doesnt work
any suggestions?
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi
Does anyone know how to prevent a user from moving a ToolStrip from one ToolStripContainer into another? The scenario is that I have two non-TopLevel forms on a form, both have a ToolStripContainer and each ToolStripContainer has one ToolStrip. I am able, by default, to drag the ToolStrip from one ToolStripContainer into the other ToolStripContainer.
I'm pretty surprised that this is default behaviour and that there doesn't appear to be a simple 'AllowToolStripToChangeContainers' boolean to stop this happening.
The only 'solution' to this I could find on the net (after almost a day of trawling) was to trap the ControlAdded event on the ToolStripPanel and if the ToolStrip being added doesn't belong (originally) to that ToolStripPanel, then remove it and add it back to its original ToolStripPanel.
This 'works' in so much as it works, but there is a very annoying flicker and mouse judder when the ToolStrip is immediately removed then added.
I'd really appreciate any help
Thanks
Rob
|
|
|
|
|
Hi! I would like to export my drawing created in picture box using GDI+ into bitmap format. But it seem I am only getting a white blank screen. Can anyone help me to solve it? Thanks a lot.
using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Collections.Generic;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Documents;
using System.Windows.Markup;
using StudentToolkit;
namespace test_drag
{
public partial class Window1
{
private Graphics g;
private System.Drawing.Pen pen1;
Bitmap bitmap;
Font font;
List<Concept> objList = new List<Concept>();
float x;
float y;
bool down = false;
int selectedIndex = -1;
public Window1()
{
this.InitializeComponent();
bitmap = new Bitmap(pictureBox.Width,pictureBox.Height);
g = Graphics.FromImage(bitmap);
Concept obj1 = new Concept("Rect", "Rect1", System.Drawing.Color.Black, 20, 20, 5, 5);
objList.Add(obj1);
Concept obj2 = new Concept("Oval", "Oval1", System.Drawing.Color.Blue, 20, 20, 40, 30);
objList.Add(obj2);
Concept obj3 = new Concept("Oval", "Oval1", System.Drawing.Color.Red, 20, 20, 80, 30);
objList.Add(obj3);
Concept obj4 = new Concept("Line", "line1", System.Drawing.Color.Aqua, 4, 80, 4, 50);
objList.Add(obj4);
font = new Font("Arial", 10);
// Insert code required on object creation below this point.
}
private void pictureBox_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (objList != null)
{
foreach (Concept obj in objList)
{
pen1 = new System.Drawing.Pen(obj.Brush_color, 1);
if (obj.Con_shape == "Rect")
e.Graphics.DrawRectangle(pen1, obj.XPos, obj.YPos, obj.Width, obj.Height);
else if (obj.Con_shape == "Oval")
e.Graphics.DrawEllipse(pen1, obj.XPos, obj.YPos, obj.Width, obj.Height);
else if (obj.Con_shape == "Line")
e.Graphics.DrawLine(pen1,obj.Height, obj.Width, obj.XPos, obj.YPos);
pen1.Dispose();
}
}
}
private void export_Click(object sender, RoutedEventArgs e)
{
int width = bitmap.Width;
int height = bitmap.Height;
int i, j;
for (i = 0; i < width; i++)
{
for (j = 0; j < height; j++)
{
System.Drawing.Color pixelColor = bitmap.GetPixel(i, j);
System.Drawing.Color newcolor = System.Drawing.Color.White;
bitmap.SetPixel(i, j, newcolor);
}
}
//
bitmap.Save(@"C:\concept1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
MessageBox.Show("The created concept map has been exported to your local drive");
}
}
}
|
|
|
|
|
yuenli wrote: But it seem I am only getting a white blank screen
yuenli wrote: System.Drawing.Color newcolor = System.Drawing.Color.White;
bitmap.SetPixel(i, j, newcolor);
led mike
|
|
|
|
|
|
Copy over your current code export_Click method with this...
private void export_Click(object sender, RoutedEventArgs e) {
bitmap.Save(@"C:\concept1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
MessageBox.Show("The created concept map has been exported to your local drive");
} Glad I could help,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hi! Thanks a lot for the suggestion but I still cannot get the whole drawing of my shapes. Once the system being run, it will draws 3 shapes on the picture box, then when click on the export button it will produce an jpeg file with 3 shapes on it and a white background. Does anyone know how to do that? Thanks.
|
|
|
|
|
If your picture is in an Image control you can simply use the Image property and save the picture to a bitmap format.
Bitmap myimage = new Bitmap(pictureBox1.Image);
string savepath = @"C:\";
imgFormat = ImageFormat.Jpeg
myimage.Save(savepath, imgFormat);
Just because we can; does not mean we should.
|
|
|
|
|
I have a database that has one table (let's call it Cyl) that has several fields "linked" to other reference tables. The associated database editing application allows the user to enter new records for through a combination of textboxes and comboboxes. The comboboxes have as their datasource the linked tables. So, the user can select an item for the new record from a pre-set list of items stored in one of the other tables. The "linked" comboboxes are databound to the source datatable (Cyl) on the SelectedValue property and their datasource and value member are the linked tables values.
This works well unless the user needs to input data for a field in the Cyl table that is not currently present in one of the linked tables (let's say a Cust table). In that case, I can get the software to save the Cust field data even if the entry for the Cust field is not in the related Cust table, but the data does not display correctly on the form because the Cust field in the Cyl table is bound to the SelectedValue of the Cust combobox and if the entry for the Cust field is not represented in the Cust table, there is no value in Cust combobox.
So, basically what I need is to have the a field from one table, say the Cust table, loaded into a combobox that users will use to enter data for a field in another table while still allowing the user to enter data that is not in the Cust table.
I hope this question makes sense.
Thanks.
|
|
|
|
|
I've been tearing my hair out (and I can ill afford that!)
for hours trying to associate an icon in the toolbox for
a user control that I created. Whatever I do, the icon is
always the stock icon (the gear).
I created a 16x16 bitmap, and made it an embedded resource
in my control. I gave the control class an attribute as follows:
[ToolboxBitmap(typeof(CommentBox), "CommentBox.bmp")]
public class CommentBox : UserControl
I have a test form class, that when I bring it up in design mode,
I would like the control to show up in the toolbox (with its
correct icon). I have tried the "Choose item..." context menu item in the
toolbox to remove the control dll, and then reinsert it...to no avail.
Any suggestions what I'm missing?
Thanks,
Tom
|
|
|
|
|
what version of Visual Studio are you using? It's possible that you have to create a custom control to associate a custom icon with it.
led mike
|
|
|
|
|
VS 2008, Mike.
Actually, I just want an icon for the tool box.
|
|
|
|
|
hain wrote: Actually, I just want an icon for the tool box.
That's what I'm talking about. I seem to remember in VS2005 (which I am still using) that you can't associate a custom Icon to a User Control. You may need to do a Custom Control if you want that feature.
led mike
|
|
|
|
|
Other than having a
protected override void OnPaint(PaintEventArgs pe)
method, what makes a custom control "custom"?
I tried inheriting my control from System.Forms.Control,
rather than UserControl.
Still no luck.
modified on Thursday, March 13, 2008 12:54 PM
|
|
|
|
|
hain wrote: what makes a custom control "custom"?
It's not that it's "custom" it's that it is not a UserControl. It implements one of more interfaces that provide various integration capacity with Visual Studio.
http://msdn2.microsoft.com/en-us/library/ms180794(VS.80).aspx[^]
here is what I have in VS2005 that works for an extenderProvider
[ProvideProperty("ShowMRUList", typeof(ToolStripMenuItem)),
ToolboxItem(true), ToolboxBitmap( typeof(ToolStrip))]
public partial class MRUMenuItem : Component, IExtenderProvider, IDisposable, ISupportInitialize
led mike
|
|
|
|
|