|
Thank you so much, Mr. BoneSoft!
|
|
|
|
|
|
I know how to add a new line in streams, but how can I delete all the lines?
|
|
|
|
|
Basically you can't you have to create a new stream, write everything up to the lines you want to delete, forward over the lines to delete and write the rest of the file.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
huuhh??? there is no way to delete everything in that file and then add stuff i want?
|
|
|
|
|
There is but not in the way you asked, you implied that you wanted to delete specific lines.
If you want to overwrite the file then you can create the stream using:
FileStream baseStream = new FileStream("path", FileMode.CreateNew); Which will overwrite the file, you can then use this stream as the basis for higher-level streams such as the TextWriter.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
hellow to all i am trying to bind combobox , and to put in it data from database ,
i had write the following code ,
try
{
string sConnection = @"provider=microsoft.jet.oledb.4.0;data source=C:\BIG_Project.mdb";
System.Data.OleDb.OleDbConnection OleDbConn = new System.Data.OleDb.OleDbConnection(sConnection);
System.Data.DataSet ds1 = new System.Data.DataSet("tbl_Users_Catagory") ;
string OleDBUserCatagory = "SELECT * FROM tbl_Users_Catagory";
System.Data.OleDb.OleDbDataAdapter OleDBAdptrUserCatagory = new System.Data.OleDb.OleDbDataAdapter(OleDBUserCatagory,OleDbConn);
OleDBAdptrUserCatagory.FillSchema(ds1,System.Data.SchemaType.Source,"tbl_Users_Catagory");
OleDBAdptrUserCatagory.Fill(ds1,"tbl_Users_Catagory");
cmb_Catagory.DataSource = ds1;
cmb_Catagory.DisplayMember = "Catagory_Name";
cmb_Catagory.ValueMember = "Catagory_Num";
cmb_Catagory.SelectedIndex = -1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
i recive this message , could not bind to the new display member
thxx for anyhelp ,
|
|
|
|
|
Um, you might have done this, but check the spelling on the 'Catagory_Num' column. (By the way, the correct spelling is 'Category'.
|
|
|
|
|
Hi guys!
I am a newbie in C# and I need your help. I have a main menu form and an add form, when I click on the add form on the main menu, I am first calling checkfile() function to see if a .ini file exists, if it does then it is supposed to continue opening the add form and if the file doesn't exist then I want it to do nothing, not open the add form but instead stay on Main form. Please see the code below, I have put in CAPS what I want to do. If there is any other trick then please suggest. Thank you guys in advance. PS. Main form always stays open even when add form is open
public int CheckFile()
{
string NameOfFile = "C:\\CB\\Config.ini";
FileInfo cmdNew = new FileInfo(NameOfFile);
if(cmdNew.Exists == false)
{
DialogResult Result;
Result=MessageBox.Show(this, "Please Create New Setup to
Continue?", "SelecSoftware CB",
MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if(Result==DialogResult.Yes)
{
//HERE I WANT TO DO NOTHING, CANCEL THE CLICK EVENT AND STAY ON MAIN MENU
}
}
}
//Here is the click event
private void cmdAdd_Click(object sender, System.EventArgs e)
//This function uses an object to open the Add Dealer code form
{
//When clicked I call the checkfile function
CheckFile();
AddDC frmAddDC = new AddDC();
frmAddDC.cmdDelete.Visible=false;
frmAddDC.cmdSave.Location=new System.Drawing.Point(83, 624);
frmAddDC.cmdExit.Location=new System.Drawing.Point(211, 624);
frmAddDC.ShowDialog();
}
sasa
|
|
|
|
|
Hi sasa,
You could work it this way:
1) In your CheckFile function and inside the if clause, return a value from the function which is meaningful to your cmdAdd_Click function, such as -1. Then in your cmdAdd_Click function, simply use the return keyword if CheckFile returns that value (in this case -1). It would look like this:
public int CheckFile()
{
...
if(!cmdNew.Exists)
{
...
if(Result == DialogResult.Yes)
return -1;
}
...
return 1;
}
private void cmdAdd_Click(object sender, System.EventArgs e)
{
if(CheckFile() == -1)
return;
AddDc frmAddDC = new AddDC();
...
} Hope that helps!
Sincerely,
Alexander Wiseman
|
|
|
|
|
Hi Alexander!
Thank you and I appreciate your help big time. I had it kind of working before you sent this to me by including the checkfile code in the click code and using return; but I like your code and I will try that. Thanks again.
Sasa
sasa
|
|
|
|
|
How do I get the designer to give me a drop down list of available choices for a custom property?
e.g.
class MyControl : UserControl
{
public string SomeProperty
{
...
}
}
When using the designer, looking at the property for 'SomePrpoerty' I want there to be a drop down that consists of a few strings 'Option1', 'Option2', etc. I can't use enums becuase the list of strings that are choices (option1, iption2) is created dynamically based on other content... I tried to return ArrayList from SomeProperty but then I get a dialog in te designer... Thanks in advance.
Brandon
|
|
|
|
|
You will need to properly decorate it with Attributes. This[^] article will give you the overview. There should be a link to a second article from here that also covers it. Most of your Attributes will live in System.ComponentModel and System.ComponentModel.Design.
|
|
|
|
|
Out friggin' standing... Works perfect. Thanks for the help!
|
|
|
|
|
I am trying to write a website using C# Code behind, and was wondering if it was possiable to check the clients registry from website to see if they have a program installed ("Intel - Integrted Performace Primitives").I would also like to be able to see if the version of my client software they have is up-to-date.
If the user does not have the program installed i would like to send it to them using BITS 2.0, same applies for the client software.
Kind Regards j1mb0jay
|
|
|
|
|
heh heh --- can you say 'major security violation' ?
|
|
|
|
|
Thank you for the reponse, but it wasnt much help. I dont want to add, edit, delete, move, copy any of the information from the registry i just want to know if they have the program i stated in the question installed on their machine, as this means the download size of the program will be dropped by 20MB. If you have any other sugestions that dont involve using the registry i would be happy to listen.
Regards j1mb0jay (17YO programmer)
|
|
|
|
|
Yeh, I know it isn't much help...but the bottom line is that most system protection software will throw up alerts about your website if someone links to it and you try to even read the registry.
The typical deployment pattern that others have used is to setup download instructions as follows:
<br />
If you have never installed the software click here.<br />
<br />
If you already installed the software but want an update click here.<br />
I don't think you can avoid leaving it to the user to decide this. There are way too many sites that use such methods to start infesting worms or zombies on the unsuspecting.
Michael (55 yo developer)
-- modified at 13:07 Friday 9th June, 2006
|
|
|
|
|
Thank the Gods it's not possible!!! My God, can you imagine?!?
Visit BoneSoft.com
|
|
|
|
|
Hello i want to change the title(top left corner) programmatically. is there a way to do that?
Donkaiser
|
|
|
|
|
Form.Text property
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
Hello Donkaiser,
I assume that you mean the title of a Windows Form in your application. If you want to change the title of any Windows Forms, you simply change the "Text" property for that form, like this:
<code>
...
myForm.Text = "Some Title";
... So, if you are in your MainForm class, you would simply do this:
<code>
...
this.Text = "Some Title";
...
If that is not what you were asking, or you still need clarification, please reply with some more specific details and I will do my best to help you.
Sincerely,
Alexander Wiseman
|
|
|
|
|
Thank you that will work!
Donkaiser
|
|
|
|
|
These are the requirements:
Assembly ‘Shared’ defines class named ‘SharedClass’ .
SharedClass contains field named ‘Info’.
Assembly ‘Runtime’ defines class named ‘Manager’
‘Manager’ should be allowed to read and change field ‘Info’ on the instance of SharedClass.
Assembly ‘GUI’ defines class named ‘Client’.
‘Client’ can only read from field ‘Info’.
Can somebody help outline design that supports such requirements.
Thanks in advance,
Elina
|
|
|
|
|
I tried writing an answer for this, but there are still some missing pieces.
For example does Runtime own SharedClass or is SharedClass a static class that is visible to both Manager and Client? You did not say but imply that SharedClass is an instance class so someone must contain it.
Then there is the way it is accessed. If you have a containing class and expose a method to do the read/update, you can alway incorporate a Context class that each caller would implement. The context would help the setter in SharedClass determine if the update is allowed in the given Context.
One possibility:
SharedClass exposes GetInstance(Context context)
context is fed to the instance which is used to determine if the setter should be active.
Another possibility:
SharedClass is static and the access to info is exposed:
public static bool UpdateInfo( object info, ContextClass context )
context contains the AssemblyName of the caller.
|
|
|
|