|
please write your queary before clicking the save button
Sreejith S S Nair
|
|
|
|
|
please write your queary before clicking the sumit button
Sreejith S S Nair
|
|
|
|
|
Hi!
Now what...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi ,i come from china,as a beginner.i met with some diffculties in my new project ,that is how to improve the speed of reading data from CD-ROM ?i built two FileStreams,one is Read data from CD-ROM,another is write data to harddisk,there is a buffer between two operation, can you give me some effesional advice to complete this new project,thank you !if you have some advice or good method please sent email to agu9899@163.com .The following is my source code :
using System;
using System.IO;
using System.Collections;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
namespace EditDVDFile
{
///
/// ClsCompex 的摘要说明。
///
public class ClsCompex
{
public static int m_progressVal;
public static bool m_bWork=false;//是否在进行读写操作
class CFileReadBuf
{
public int m_nBufLen=1048576;//1048576;
public byte[] m_Buf= new byte[1048576];//[1048576];
public int m_nReadLen;
public bool m_bWrite=false;//是否在进行写操作
public IAsyncResult m_AsyncResult;
}
bool m_bOneWork;
long t1,t0;
CFileReadBuf m_FileBuf1=new CFileReadBuf();
CFileReadBuf m_FileBuf2=new CFileReadBuf();
public FileStream m_FileStreamRead;
FileStream m_FileStreamWrite;
AsyncCallback CallBackMethodRead;
AsyncCallback CallBackMethodWriteEnd;
public ArrayList m_arFileName=new ArrayList();
public ClsCompex()
{
}
public void DVDCompex(ArrayList arTemFileName,string DesPath)
{
m_bWork=true;
//使用文件名来构造FileStream流
m_arFileName=arTemFileName;
string strFileName=arTemFileName[0].ToString();
m_FileStreamRead =new FileStream(strFileName,FileMode.Open,FileAccess.Read, FileShare.ReadWrite,1048576,true);
m_FileStreamWrite=new FileStream(DesPath,FileMode.Append, FileAccess.Write, FileShare.ReadWrite, 1048576, true);
//构造回调方法
CallBackMethodRead =new AsyncCallback(ReportReadingProgress);
CallBackMethodWriteEnd =new AsyncCallback(ReportWriteEndProgress);
//启动异步读取操作
m_bOneWork=true;
t0 = Environment.TickCount;
//System.Diagnostics.Debug.WriteLine("Start Reading Progress......");
m_FileStreamRead.BeginRead(m_FileBuf1.m_Buf,0,m_FileBuf1.m_nBufLen,CallBackMethodRead,m_FileBuf1);
}
public void ReportWriteEndProgress(IAsyncResult asyncResult)
{
}
public void ReportReadingProgress(IAsyncResult asyncResult)
{
try
{
//System.Diagnostics.Debug.WriteLine("..........ReportReadingProgress..........");
CFileReadBuf m_FileBufRead;
CFileReadBuf m_FileBufWrite;
if(m_bOneWork)
{
m_FileBufRead=m_FileBuf1;
m_FileBufWrite=m_FileBuf2;
m_bOneWork=false;
}
else
{
m_FileBufRead=m_FileBuf2;
m_FileBufWrite=m_FileBuf1;
m_bOneWork=true;
}
m_FileBufRead.m_nReadLen=m_FileStreamRead.EndRead(asyncResult);
//System.Diagnostics.Debug.WriteLine("Current stream position is : "+m_FileStreamRead.Position.ToString()+" byte");
if(m_FileBufWrite.m_bWrite)
{
m_FileStreamWrite.EndWrite(m_FileBufWrite.m_AsyncResult);
m_FileBufWrite.m_bWrite=false;
}
if(m_FileBufRead.m_nReadLen==0)
{
t1 = Environment.TickCount;
//System.Diagnostics.Debug.WriteLine(m_arFileName[0].ToString()+"ReportWritrEndProgress "+((t1-t0)/1000)+"s");
m_FileStreamRead.Close();
m_arFileName.RemoveAt(0);
if (m_arFileName.Count>0)
{
string strTemName=m_arFileName[0].ToString();
m_FileStreamRead=new FileStream(strTemName,FileMode.Open,FileAccess.Read, FileShare.ReadWrite,1048576,true);
m_FileStreamRead.BeginRead(m_FileBufWrite.m_Buf,0,m_FileBufWrite.m_nBufLen,CallBackMethodRead,m_FileBufWrite);
}
else
{
m_FileStreamWrite.Close();
}
m_bWork=false;
return;
}
m_FileBufRead.m_bWrite=true;
m_FileBufRead.m_AsyncResult=m_FileStreamWrite.BeginWrite(m_FileBufRead.m_Buf,0,m_FileBufRead.m_nReadLen,null,null);
//文件读取结束
m_FileStreamRead.BeginRead(m_FileBufWrite.m_Buf,0,m_FileBufWrite.m_nBufLen,CallBackMethodRead,m_FileBufWrite);
}
catch(Exception e)
{
MessageBox.Show(e.Message,"文件读写错误提示");
m_FileStreamRead.Close();
m_FileStreamWrite.Close();
GC.Collect();
}
}
}
}
|
|
|
|
|
Use a smaller buffer. A 4 KB block (4096) is typically a good buffer size. If you use a larger block, more data must be read and written so the CD sits idly by.
Also, just a good programming tip: define your buffer size as a constant variable so you avoid any possible screw-ups (like forgetting a number when typing). This also makes it easy to change, since you change only this constant variable and recompile:
private const int BufferSize = 4096;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I need to know if my code is right to enable or disable any object in C#.net
I use if condition.. is there other way to do it?
private void optBCLA01001_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(optBCLA01001.SelectedIndex == 0)
{
optBCLA01006.Enabled = true;
}
}
|
|
|
|
|
Kind of...It all depends on what a 'optBCLA01006' is. A button?...Checkbox?... For just about all of the usual form controls like buttons and checkboxes and radio buttons, textboxes, ... this is true.
BTW: Those variable names are HORRIBLE because they are not descriptive of anything they represent.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
By default all controls that you are going to place have a Enable property that will allow user to interact with.
I think your aim is if the optionbutton is cliecked you ned to enable some control(eg: textbox or label).
am i right ?
if so. follow like this
if(radiobutton1.checked)
textboxme.Enabled=false;
else
textboxme.Enabled=true;
here if you click on your radio button it will disable the textbox and if you unchecked it will show the enable the textbox.
And on design time you have to deside what is the startup state of your control.
Sreejith S S Nair
|
|
|
|
|
Thanks... you understand me very well... But could we be more specific: I am using RadioButtonList & textbox. My code is this:
private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (RadioButtonList1.SelectedIndex ==0)
{
RadioButtonList2.Enabled=true ;
textbox1.Enabled = true;
}
else
{
RadioButtonList2.Enabled=false ;
textbox1.Enabled = false;
}
}
I am using ASP.NET Web Application, Visual C# Project. The lunching of Internet Explorer is successful without error in build solution and start. My only problem is my code don't do anything. My code will not enable or disable any RadioButtonList or textbox. By the way my default settings of properties in "RadioButtonList2" in my code is disable and I want my code to enable it once the selectedindex is equal to 0 which is the first option of the user. Thanks and more power to you and to this website!!! chiao!!!
|
|
|
|
|
sorry for this much time.cause i am not feeled well for last two days.
ok.
now i got your problem.
change the AutoPostback property of your first radiolist box control into true.by default it is false.
And then try the above mentioned code.
have a nice day
Sreejith S S Nair
|
|
|
|
|
Good Day!!!
Wonderful.... It works!!! The textbox will enable/disable as I expected!Thank you very much for helping... (Running State)But I jst want to ask if the AutoPostBack will result to refresh effect? I mean each time I change my option to the RadioButtonList the whole web application will download again and will display the new changes made by the user.
One more thing!!! How about the coding of CheckBoxList with 4 to 5 choices with corresponding textbox that will also enable each textbox if the choices are being checked. Here is my coding but it wont work as I expected:
private void checkboxlist1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(checkboxlist1.SelectedIndex == 0)
{
textbox1.Enabled = true;
}
if(checkboxlist1.SelectedIndex == 1)
{
textbox2.Enabled = true;
}
if(checkboxlist1.SelectedIndex == 2)
{
textbox3.Enabled = true;
}
if(checkboxlist1.SelectedIndex == 3)
{
textbox4.Enabled = true;
}
}
If I checked the first choice it will enable the textbox1 ang when I checked also the second choice the textbox2 will not enable, so on and so on to the other choices. The program will allow me to checked all the choices but will not enable all the corresponding texbox of each choices.
Hope you could help me figure out whats wrong with my program....
Thanks and God Bless!!!
|
|
|
|
|
Sure it will work.Write down your code on valuechange event. and try your all requirement.
if you feel any uncomfortable please let me know that.
Sreejith S S Nair
|
|
|
|
|
don't think like this. if you got a little idea that HOW ? you have to develop the remaining.
dear please use little logic and refer MSDN. This forum is for help only not for coding support.ok
try
this
if(CheckBoxList1.SelectedItem.Value.ToString()=="c1")
TextBox1.Enabled=false;
else
TextBox1.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c2")
TextBox2.Enabled=false;
else
TextBox2.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c3")
TextBox3.Enabled=false;
else
TextBox3.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c4")
TextBox4.Enabled=false;
else
TextBox4.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c5")
TextBox5.Enabled=false;
else
TextBox5.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c6")
TextBox6.Enabled=false;
else
TextBox6.Enabled=true;
Sreejith S S Nair
|
|
|
|
|
Heyas all,
Really trying my hardest to take all this information in. I come from a unix C environment and I'm finding the OO paradigm very aawkward so far, but I'm gonna keep it. My question is, If say I have a label on a form, and on a second form, I have a button that when clicked will populate the label with the text in a textbox from the first form. basically how do go about making the objects on a seperate form available from within another form. That sounds really confusing. I hope someone understands what I trying to say.
P.S. - Yes, English is my first language
kha0s
"There are 10 types of people in this world; Those that know binary and those that do not."
|
|
|
|
|
Each form you create in .net is in itself a class so if you instantiate an object of one form within the code behind for the other form you will be able to access it's components ie:
Within the Form2 code write
Form1 myForm1 = new Form1();
Then also within the Form2 code write
textboxname.DataSource = myForm1.Text.ToString();
and it should put the data in the approppriate place
Please not what I have written is very basic there is a large amount of help for questions like yours in places like this website and msdn so don't be shy dig right in an get an early understanding of OOP with .net
|
|
|
|
|
Why are you calling Text.ToString() ? The Text property is already a String . Calling ToString() is a waste.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You need to pass an instance of the first form to your second form. For example:
public class Form1 : Form
{
internal Label label1;
private Button button1;
public Form1()
{
label = new Label();
button1 = new Button();
button1.Click += new EventHandler(button1_Click);
}
private void button1_Click(object sender, EventArgs e)
{
using (Form2 form = new Form2(this))
form.ShowDialog(this);
}
}
public class Form2 : Form
{
private TextBox textBox1;
private Button button1;
private Form1 form;
public Form2(Form1 form)
{
this.form = form;
textBox1 = new TextBox();
button1 = new Button();
button1.Click += new EventHandler(button1_Click);
}
private void button1_Click(object sender, EventArgs e)
{
if (form != null) form.Label.Text = textBox1.Text;
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I need to add bitmaps to some buttons, but they are tiny bit maps. Whats the best way to create these small buttons so the small bitmaps complete cover the button ?
|
|
|
|
|
Draw them yourself. Override OnPaint and use PaintEventArgs.Graphics to draw the Bitmap s using Graphics.DrawImage . Give it the bounding rectangle of the Button and the image will be stretched.
You could also try searching CodeProject. I know I've seen several articles covering this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
First off thanks for the response. I have tried searching botht the artciles and messageboad but I cannot find anything on point.
I think I understand what you mean, but i'm not sure if that will give me what I want. I'd like to fit the button to the picture, not stretch the picture to the button. Is your solution still the same ?
I assume I will need to inherit the Button Class and create my own control in order to override the OnPaint() method ?
I've tried to create the buttons and fit to the picture using the code below, but for some reason the bottom of the picture is getting chopped off, or at least it appears to be.
Image ButtonPic = null;
Stream ImgStream=null;
int ImageHeight,ImageWidth,ButtonY,ButtonX=0;
ImgStream = this.GetType().Assembly.GetManifestResourceStream("MiniP3.PlayerPrevious.bmp");
ButtonPic = Image.FromStream(ImgStream);
btPrevious = new Button();
btPrevious.Image=ButtonPic;
btPrevious.Size = ButtonPic.Size;
btPrevious.ImageAlign=ContentAlignment.MiddleCenter;
ImageHeight = ButtonPic.Height;
ImageWidth = ButtonPic.Width;
ButtonY = (int)(pnButtons.Height-ImageHeight)/2;
btPrevious.Location = new Point(ButtonX,ButtonY);
this.btPrevious.Click += new System.EventHandler(this.PreviousClick);
pnButtons.Controls.Add(btPrevious);
|
|
|
|
|
Yes, the best way is to extend the Button class with your own. This makes it easy to add new image buttons as the derivative class encapsulates the code necessary to display an image.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I just found Marc Clifton's Article.
|
|
|
|
|
Hello All, I have an ASP.net application that is currently using the push method and displaying reports off of ADO.net datasets. I am struggling with a design method for the following questions:
1. .NET treats each crystal report you add to your project as a class and I am using a several reports and the ReportDocument class to set datasources for each one and so on. Depending on which report my users select in an aspx page i show them the report they want by creating an object of the type of report they selected. I am wondering if I can create say Object myobj = new Object() and depending on what report they select cast the general myobj object into the specific type of the report class the user selected instead of having to instantiate an instance of every type of report within my code?
Thanks for your help
Frank
|
|
|
|
|
Depending on how you display the list of reports, you can use Activator.CreateInstance to create an instance of the report. Cast that to the ReportDocument base class and call SetDataSource with your ADO.NET DataSet .
For instance, if you use a ListBox you could set the display name to whatever you want, but set the value for each item to the corresponding .rpt name. Since this gets compiled to a class with the same name using a namespace that is your project's root namespace (the project name by default) plus any folders it's in, you could do something like this:
string reportName = "MyWebApp.Reports." + listBox1.SelectedValue;
ReportDocument report = Activator.CreateInstance(reportName, "MyWebApp.dll");
report.SetDataSource(dataSet1); Of course, you should add error handling like try-catch blocks and conditionals (like checking for null values, etc., since throwing exceptions is expensive).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there any way to add a menu item to an existing drop down menu in Excel using the Visual Studio Tools for Microsoft Office 2003? I want to add a menu item to the drop down list you get when you right click on a cell on the worksheet. I also want to add an event handler for that new menu item.
Thanks for any help
Mike.
|
|
|
|