|
Hello monrobot13,
First, I wonder if is there a way to hide or set "visible" property for each tab item?
Secondly, create a seperate class for each tab item. Instantiate an instance from each class for storing and updating data specific for each tab item. Do not destroy these objects until you terminate your app?
Just my wild ideas,
Hope you get good tips from others
Khang Nguyen
|
|
|
|
|
Khang Nguyen wrote:
First, I wonder if is there a way to hide or set "visible" property for each tab item?
The tabs do have a visible property, but setting it to false doesn't hide the tab. The only way I've found to make it hide is to complelety remove it from the control.
Khang Nguyen wrote:
Secondly, create a seperate class for each tab item. Instantiate an instance from each class for storing and updating data specific for each tab item. Do not destroy these objects until you terminate your app?
Thats a pretty good idea. Do you think it would be a good idea to then hold these items in an array for easy access?
- monrobot13
|
|
|
|
|
Thats a pretty good idea. Do you think it would be a good idea to then hold these items in an array for easy access?
That sounds like a good idea to me. (Khang Nguyen)
|
|
|
|
|
I want to recreate this this section of code for a windows application.
protected System.Web.UI.HtmlControls.HtmlInputFile Upload;<br />
<br />
private void Button1_Click(object sender, System.EventArgs e)<br />
{<br />
if (Upload.PostedFile != null)<br />
{<br />
HttpPostedFile File = Upload.PostedFile;<br />
<br />
byte[] Data = new Byte[File.ContentLength];<br />
File.InputStream.Read(Data,0,File.ContentLength);<br />
<br />
int i = 0;<br />
<br />
for (i=0;i<Data.Length;i++)<br />
{<br />
TextBox1.Text += Data[i].ToString(); <br />
}<br />
<br />
object[] obj = new object[1]; <br />
<br />
obj[0] = Data;<br />
<br />
<br />
<br />
SqlHelper.ExecuteNonQuery(connectionString,"sp_img",obj); <br />
<br />
}<br />
<br />
}
Any help would be greatly appreciated
Da Intern
|
|
|
|
|
I haven't tried the code that i am going to write but i think it will work.
You want to store binary data in a db field if i guessed write, so:
<br />
System.IO.Filestream newf = System.IO.File.OpenRead(filename);<br />
byte[] data = new byte[newf.length];<br />
newf.Read(data,0,newf.length);<br />
<br />
<br />
<br />
<br />
for (i=0;i {<br />
TextBox1.Text += Data[i].ToString(); <br />
}<br />
<br />
object[] obj = new object[1]; <br />
<br />
obj[0] = Data;<br />
<br />
<br />
<br />
SqlHelper.ExecuteNonQuery(connectionString,"sp_img",obj);
Try it i think it will work
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
is it possible to carry out SQL format selects directly onto datasets?
For example lets say I have a dataset with the following format :
<br />
col1 col2 col3 col4<br />
row1 a b c d<br />
row2 e f g h<br />
row3 i j k l<br />
Is there a way to run the following SQL command :
dsResult = SELECT col2, col3, col4 FROM dsSource.Tables[0] WHERE col1 = 'a'
Which would return the following into dsResult
<br />
col2 col3 col4<br />
b c d<br />
|
|
|
|
|
<br />
DataRow row = dsSource.Tables[0].Rows.Find( new object[] {'a'} );<br />
Good Luck
Alex Kucherenko
|
|
|
|
|
Unfortunatly I probably over simplified things, so although the code you posted works perfectly it wont work in my code.
This is the scenario I am up agaisnt. I have a populated dataset with a single table, multiple rows, and multiple columns.
I need to add a column to this dataset but it has to be at position 7 (of 40), i.e. not at the end as columns.Add() would do.
The reason for asking about the possibilites of using selects is that the only way I can imagine doing this is to :
1) foreach through each row in the source dataset
2) Select all the data into a comma seperated string.
3) Inserting the new column (techincally another '',) where needed.
4) Build a new datarow from the string.
5) Insert the new datarow into another dataset
This all seems way to over complex for what originally seemed like a simple problem. I am sure I am missing something here put I cant put my finger on what it is.
|
|
|
|
|
why do want the col in a specified position? you can create a Dataview but i don't think this is the best solution .If you want to show your data in a datagrid you can create a Tablestyle with specified columnstyles for this grid, so you can put the cols in specified positions look this piece of code:
System.Windows.Forms.DataGridTableStyle tempstyle=new System.Windows.Forms.DataGridTableStyle();
tempstyle.AllowSorting=true;
tempstyle.GridLineStyle=System.Windows.Forms.DataGridLineStyle.Solid;
tempstyle.MappingName=[tablename];
System.Windows.Forms.DataGridColumnStyle tempcol;
tempcol=new System.Windows.Forms.DataGridTextBoxColumn();
tempcol.HeaderText="Κωδικός";
tempcol.MappingName=[fieldname];
tempcol.NullText="";
tempcol.Width=50;
tempstyle.GridColumnStyles.Add(tempcol);
In this way add the columns you want in the position you like.
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
OR
<br />
DataView view = new DataView( dsSource.Tables[0], "col1 = " + ... Value ..., "", DataViewRowState.CurrentRows );<br />
Good Luck
Alex Kucherenko
|
|
|
|
|
Lets say I have a Dataset which contains one table, multiple datarows, and multiple populated datacolumns.
I want to add another column to this dataset BUT I need to add it at a specific postion. For example there are 20 datacolumns and I want to insert a column at position 7 (shuffling all the others up)
I have been looking at Columns.Add() but I cant find any functionality to allow me to specify postion as this seems to just add the new column to the end of the datarow.
Does anybody know of a way of doing this, without disassembling the dataset and rebuilding with the new column.
|
|
|
|
|
<br />
DataSet dsSet;<br />
DataTable table;<br />
<br />
<br />
DataColumn[] columns = new DataColumn[ table.Columns.Count ];<br />
table.Columns.CopyTo( columns, 0 );<br />
<br />
table.Columns.Clear(); <br />
<br />
ArrayList lst = new ArrayList( columns );<br />
<br />
lst.Insert( ... );<br />
lst.RemoveAt( ... );<br />
lst.Add( ... );<br />
<br />
table.Columns.AddRange( ( DataColumn[] )lst.ToArray( typeof( DataColumn ) ) );<br />
<br />
lst.Clear();<br />
Only one note... I don't know what will happens with DataTable Data...
Good Luck
Alex Kucherenko
|
|
|
|
|
That works brilliantly but as you mentioned there is a problem with the data, it isnt carried across into the dataset.
The code I am using at the moment is this :
<br />
DataColumn[] columns = new DataColumn[ dsSource.Tables[0].Columns.Count ];<br />
dsSource.Tables[0].Columns.CopyTo( columns, 0 );<br />
ArrayList lst = new ArrayList( columns );<br />
dsSource.Tables[0].Columns.Clear();<br />
<br />
DataColumn dc = new DataColumn();<br />
lst.Insert(7, dc);<br />
<br />
dsSource.Tables[0].Columns.AddRange( ( DataColumn[] )lst.ToArray( typeof( DataColumn ) ) );<br />
<br />
lst.Clear();<br />
Currently working on getting the data across
|
|
|
|
|
Try such way:
- create copy of DataColumns
- change in copy name to unique one (add prefix to names)
- add copy DataColumns to collection
- ??? map data of old columns to new columns ??? (how to do that???)
- remove old columns from collection
- change names of columns to default one (remove prefix from names)
I don't know how to re-map columns data, but i think this is easier to do then copy all data from dataset...
Good Luck
Alex Kucherenko
|
|
|
|
|
I am currently working on a variation of the code you posted earlier.
Rather than working with columns I am working with the datarows as these seem to maintain the data within them
this is the code I have at the moment
<br />
DataRow[] rows = new DataRow[ dsSource.Tables[0].Rows.Count ];<br />
dsSource.Tables[0].Rows.CopyTo(rows, 0);<br />
ArrayList lst = new ArrayList( rows);<br />
DataSet dsNew = new DataSet();<br />
<br />
foreach(DataRow drs in lst)<br />
{<br />
ArrayList lst2 = new ArrayList(drs.ItemArray);<br />
lst2.Insert(3, "Insert Value");<br />
DataRow ndr = dsNew.Tables[0].NewRow();<br />
<br />
<br />
dsNew.Tables[0].Rows.Add(ndr);<br />
}
My only problem is getting the arraylist of row values back into the new datarow, but I have only been stuck here for a few minutes, hopefully the solution will come to me soon
|
|
|
|
|
Well here it is, this piece of code will take a dataset (dsSource) add a column and write the results into a second dataset (dsNew).
Its dirty, it aint pretty, but it does the job (ish)
<br />
DataRow[] rows = new DataRow[ dsSource.Tables[0].Rows.Count ];<br />
dsSource.Tables[0].Rows.CopyTo(rows, 0);<br />
ArrayList lst = new ArrayList( rows);<br />
DataSet dsNew = new DataSet();<br />
dsNew.Tables.Add();<br />
<br />
for (int i=0; i<dsSource.Tables[0].Rows[0].ItemArray.Length + 1; i++)<br />
dsNew.Tables[0].Columns.Add();<br />
<br />
foreach(DataRow drs in lst)<br />
{<br />
ArrayList lst2 = new ArrayList(drs.ItemArray);<br />
lst2.Insert(3, "INSERT VALUE");
DataRow ndr = dsNew.Tables[0].NewRow();<br />
ndr.ItemArray = lst2.ToArray(); <br />
dsNew.Tables[0].Rows.Add(ndr);<br />
}<br />
EDIT : hmm, the code tags seem to have messed up that for loop it should be :
for (int i=0; i
|
|
|
|
|
how do i get windows to notify me of multiple events? eg a mouse click and a mouse over another contorl at the same time?
i have a button and a panel, when i click and hold the mouse button down over the button an event is fired, if i keep the mouse button clicked and move over the panel the mouseover event for the panel is not fired, it is fired only when i relase the mouse button
is there a way of getting round this problem? i need to know the mouse over events occuring.
thanks
|
|
|
|
|
How can I trap an event when a column of listview control is resized in C#?
|
|
|
|
|
Hi.
I'm having problems with code that worked until just recently. I have a C# komponent which uses SmtpMail to send an e-mail, but now I get an exception. With stack trace it looks like follows:
[SEHException (0x80004005): External component has thrown an exception.]
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) +0
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +64
System.Web.Mail.SmtpMail.Send(MailMessage message) +150
The component still works on my normal computer (where I run XP) and the only thing I can remember doing on the mashine acting as server (running Win2000) is that I uninstalled IE 6, because I wanted to see a webpage in IE 5.5. It didn't feel like it should matter but now the component does not work. I have reinstalled IE 6 and updated with all the latest patches and so on, but it still wont work. Can there be some setting that may have changed and now is preventing an instance from some component to be created?
Code sample:
MailMessage vscMail=new MailMessage();
vscMail.To="myemail@hotmail.com";
vscMail.From="myemail@hotmail.com";
vscMail.Subject="Sending an e-mail";
vscMail.Body="Hello world!";
SmtpMail.SmtpServer=strSmtpServer;
SmtpMail.Send(vscMail);
Any idéas or hints?
Thanks
/EnkelIk
|
|
|
|
|
Version 1.0.3705 on both. On the one where it works I have complete Visual Studio .Net installed, on the one it doesn't work I just have the framework.
|
|
|
|
|
I tried installing Framework 1.1, but unfortunatelly it didn't help.
|
|
|
|
|
So far .net 1.1 seems neither to have helped nor harmed -it still doesn't work.
I got the idea that the trouble could be in the connection to the smtp-server so I tried setting the SmtpMail.Server to "localhost" (and also not to set it at all) but the exception was the same, even when I stopped the Default SMTP virtual server running on the "win2000-machine". My conclusion is that the exception occurs before the application even tries to connect to the smtp-server.
Do you think uninstalling .net frameworks all together and then reinstalling it might help?
Thanks
/EnkelIk
|
|
|
|
|
Ok. That sounds like a good idea but there are two problems: 1. I do not have Visual Studio on the mashine 'causing trouble', and if I run the program, "physically" on that mashine, in debugger in Visual Studio on my other mashine everything goes fine -the exception is not thrown.
2. To find out what was going wrong I would have to debug into the SmtpMail.Send function and I have not found a way to do that.
The reason why I hoped uninstalling and reinstalling .net framework would make a difference is the fact that the SmtpMail.Send worked on both mashines earlier...
Thanks
/EnkelIk
|
|
|
|
|
I need to monitor if there're any change to some files after some interval of time. To do this, i have to somehow know when the file is last modified. We can do it easily by right-clicking on the file and click on its property. But, in terms of coding, i need to know how to read the property/ where to find information about a file's property.
Anybody knows? please help me out
thanks
puppiesLover
|
|
|
|
|
Do you need to be notified when it's modified, or do you just want to store the modified time at one point and compare it again later?
If you just want to store and compare then does the System.IO.FileInfo class do what you'd like?
<br />
using System;<br />
using System.IO;<br />
<br />
FileInfo info = new FileInfo( "myfilename" );<br />
DateTime modified = info.LastWriteTime;<br />
n!
|
|
|
|