|
How I can Save All text in richTextBox as image
|
|
|
|
|
If you take this [^]article as the basis (ok, it adds extra things as syntax highlighting but those can be removed). All you need to do then is call DrawEditControl with a Graphics object created from an image rather than a PrintDocument. E.g.
private void Print()
{
using (Bitmap image = new Bitmap(width, height, PixelFormat.Format24bppRgb))
{
using (Graphics gfx = Graphics.FromImage(image))
{
DrawEditControl(gfx);
}
image.Save(filename, ImageFormat.Bmp);
}
}
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Hi
I'm sure I'm missing something, but I can't see what....
I take data from form1 to form2, make my changes and click on form2's save button. It updates correctly the form1's datagridview but doesn't save the data in the database.
Can anyone see why it doesn't save in the database?
Kind regards,
simsen
My code:
private DataViewManager dsView;
private DataSet ds;
private OleDbDataAdapter da1;
private OleDbDataAdapter da2;
private OleDbCommandBuilder cBuilderKunder;
private OleDbCommandBuilder cBuilderFaktura;
string myDB = "c:\\ANSI\\Fakturasystem.mdb";
private void btnRetKunde_Click(object sender, EventArgs e)
{
// Find den aktuelle row der er selected når der dobbeltklikkes.
CurrencyManager cm = this.BindingContext[dgrKunder.DataSource,
dgrKunder.DataMember] as CurrencyManager;
if (cm != null)
{
DataRowView rowView = cm.Current as DataRowView;
if (rowView != null)
{
// Nu har vi row'en der skal editeres.
// Og vi starter din edit form op.
using (RetKunde ef = new RetKunde())
{
// Initialiserer din edit forms tekstfelter
// til de eksisterende data.
ef.Navn = rowView["Navn"].ToString();
ef.Adresse = rowView["Adresse"].ToString();
ef.Postnr = rowView["Postnr"].ToString();
ef.Byen = rowView["Byen"].ToString();
ef.Telefonnr = rowView["Telefonnr"].ToString();
ef.Mobilnr = rowView["Mobilnr"].ToString();
ef.EmailAdr = rowView["EmailAdr"].ToString();
ef.Noter = rowView["Noter"].ToString();
// Vi viser formen som en dialog, og tester hvilken knap brugeren har
trykket på vha. DialogResult.
if (ef.ShowDialog() == DialogResult.OK)
{
// Hvis brugeren trykkede på OK sætter vi værdierne i Row'en til de værdier
brugeren har tastet ind.
rowView["Navn"] = ef.Navn;
rowView["Adresse"] = ef.Adresse;
rowView["Postnr"] = ef.Postnr;
rowView["Byen"] = ef.Byen;
rowView["Telefonnr"] = ef.Telefonnr;
rowView["Mobilnr"] = ef.Mobilnr;
rowView["EmailAdr"] = ef.EmailAdr;
rowView["Noter"] = ef.Noter;
//opdaterer Adapteren
builderOpbygning();
da1.Update(ds);
}
}
}
}
}
private void builderOpbygning()
{
cBuilderKunder = new OleDbCommandBuilder(da1);
cBuilderFaktura = new OleDbCommandBuilder(da2);
da1.UpdateCommand = cBuilderKunder.GetUpdateCommand();
da1.DeleteCommand = cBuilderKunder.GetDeleteCommand();
da2.UpdateCommand = cBuilderFaktura.GetUpdateCommand();
}
|
|
|
|
|
|
I have read some of the articles - and thought I programmed it correctly - it doesn't help me to read them again ...... I know the code worked - before I bind it by myself and not used the wizard.....
|
|
|
|
|
I saved directly into the database instead of using the update command.
|
|
|
|
|
Hi guys
I'm wondering if I should set the objects that I create to null after I'm done with it... let's say I create FileStream object in private method, after I close the object should I write:
FileStreamObj.close();
FileStreamObj = null;
or:
FileStreamObj.close();
Is enough?
TIA
|
|
|
|
|
It's a good idea if the object can be accessed afterwards because then the code can test whether FileStreamObj is null before trying to access it and getting ObjectDisposedException which will consume more resources. If nothing else can access it after it's disposed, e.g. it's used as a variable in a function of some sorts then there probably isn't any need.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
|
Closing the file is enough.
Only set it to null if the reference is going to hang around and some code may try to use it. By setting it to null in that scenario you have a nice easy test to see if it is valid e.g. if (FileStreamObj == null)
|
|
|
|
|
I have an array full of values of type short?[] and want to display them in a MultiLine Textbox which requires values of type string[].
I can not figure out how to convert between the two value types.
Here is my code that I thought would work but I get error - "can not convert type short?[] to string[] "
NumArray = new short?[37];<br />
<br />
public void SetFormData()<br />
{<br />
textbox1.Lines = new string[37] ;<br />
textbox1.Lines = (string[])NumArray; <br />
}
Haz
|
|
|
|
|
You can't convert like that. Try this:
string[] stringArray = new string[37];
for(int i=0; i<37; i++)
{
short? num = NumArray[i];
if (num != null)
stringArray[i] = NumArray[i].ToString();
else
stringArray[i] = "";
}
textbox1.Lines = stringArray;
|
|
|
|
|
Thanks for your speedy response.
Your solution works really well in my program.
Haz
|
|
|
|
|
Wouldn't these be useful? Use like e.g.:
<br />
[Editor(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(UITypeEditor))]<br />
partial string FileName;<br />
I made a dataset, but to some string properties I want to attach the EditorAttribute so I can dump the table in a DataGridView and I'd get the file selector thing for that specific column. Or is there another way to achieve this? (Other than implementing GetProperties ofcourse, I'm a lazy bastard ).
Wout
|
|
|
|
|
wout de zeeuw wrote: Wouldn't these be useful? Use like e.g.:
What would be useful? Partial properties?
To be honest I don't see the point.
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
You can't touch the designer generated dataset classes, but you can use the partial class feature to add e.g. properties to it. So continuing on this line of thought, I'd like to be able to attach attributes to generated properties.
Just a thought.
Wout
|
|
|
|
|
wout de zeeuw wrote: You can't touch the designer generated dataset classes
Eh? If that were the case it'd be going against one of the key .NET principles of representing everything in code.
Just expand the DataSet.xsd node and open DataSet.Designer.cs , just remember not to regenerate the dataset once you've made the changes.
Infact once the dataset has been generated you can remove the schema and just include the DataSet.Designer.cs file.
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
I know... usually I keep the xsd, because things change anyway, and the (query) designer is pretty neat. With the partial classes you can at least add stuff, like transactions to the class without needing to touch the designer generated code (pretty standard way of working). It's just a pity that attaching attributes in the same way is not possible.
Wout
|
|
|
|
|
I suppose. But then the designer would have to be changed so that it declared the properties as partial anyway. It'd be more sensible to include a "Designer" attribute in the dataset designer.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Bwegh, this DataGridView is utterly annoying , it doesn't even respect the EditorAttribute . I wish these guys designed it to be somewhat consistent with the wonderful PropertyGrid . Seems I'll have to simulate similar behaviour by fiddling with the DataGridViewButtonColumn .
Wout
|
|
|
|
|
Just been using the DataSet designer and just realised you cannot implement partial properties. Certainly in the same way that partial classes are implemented.
What's to define which class is executed first? In partial classes the method blocks are not seperated across files they're in the same file because otherwise which order do you process them in?
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
Hi,
I am working on a http content blocker for child protection from inproper web sites. To handle the navigated web sites from internet explorer, i am using the SHDocVw.Internetexplorer. However, i could not handled the other browsers like Netscape or Opera. Thanks.
Kind Regards,
Allen
|
|
|
|
|
AAndrews wrote: Thanks.
Thanks for letting us know that you can't handle Netscape and Opera.
You havn't actually asked a question here.
I'm assuming you're asking for some help in blocking stuff from Opera & Netscape?
The best way would actually be to make the program act as a filter on the ethernet ports. I.e. all data being sent via TCP/IP is sent to your program, it does it's validation, if it fails it doesn't pass on the message (or throws an error), if it passes it allows it to continue on its path to the destination.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
Ed.Poore wrote: As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
Sounds like signature material
|
|
|
|
|
Reading it again it does doesn't it. Now how to I change the sig in CPHog...
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|