|
it is possible, but depends on how you want to have it.
do you want to get a tree hierarchy(including TreeNode.Nodes) from a XMLNode (and his childs)?
Calin
|
|
|
|
|
The following article contains a demo that shows how to create a hierarchy of TreeNode(s) based on a XML file input.
Basically, the resulted TreeView will contain the hierarchical display of Nodes as in XML file.
Please have a look XML Nodes -> Tree[^]
Calin
|
|
|
|
|
Thanks for your reply.
Actually the context is I need to convert XML Node to TreeNode and again add the treenode in a treeview control.
Its not necessary for me to read entire tree.
|
|
|
|
|
i m creating a program in c#
flow of the program is...
1. read the text file path from the registry(system in which my exe is running) the path is hard corded
2. copy the contents of that text file
3. save the contents into file in my system
unfortunately i m not able to get the file data ... can any body help me out by giving some idea to copy the data
|
|
|
|
|
arun_nadu wrote: unfortunately i m not able to get the file data
Are you unable to figure out which classes and methods you should use? Does your code not compile? Does it fail at runtime? How are people supposed to help you if they don't know what your problem is?
Tip: if you are new to file I/O in .NET, check out the System.IO namespace. All the classes you need are there.
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
sorry for the confusion given
here i m able to compile and run. as you told i m using IO classes
i have a shared file in side my pc . when ever my exe running it will copy specific text file from that pc and it should send it to my pc as i had specified my ip address.
for testing purpose i had run the exe in my pc so its getting the data from the specified file and getting copied to the shared file
|
|
|
|
|
arun_nadu wrote: i had run the exe in my pc so its getting the data from the specified file and getting copied to the shared file
Well, what's your problem?
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
Dear All
If anyone can provide me the example or url for updating the SQL table from DataGridView i have googled it but not able to found the required example
Thanks
|
|
|
|
|
I have a string with the value of "pictureBox89", a picturebox who's called pictureBox89, and another picturebox called picbox.
Now when I recieve the "pictureBox89" string is there any way I can make picbox equal pictureBox89?
I thought about
If( a == "pictureBox89")
picbox = pictureBox89;
but the thing is I have too many pictureboxes. I figured if there's a command for this I could get it over with in one line.
Thanks in advance.
|
|
|
|
|
I cant understand your logic
Where does these string values comes from and what is the range of possible values (such as pictureBox1 ,pictureBox2 ,pictureBox3 ...) and why are you taking decision
If you tell the me whole story i can give you a appropriate logic.
|
|
|
|
|
i think u can store the string "picbox"
in another string variable(suppose strPB) and make that string variable as "picturebox89"
and u can use the strPB in the places where its required
|
|
|
|
|
If I understand your question, what you are asking, is if you can associate picbox with another control, the only reference you have being the string. Off the top of my head, I'd use something like the code below:
private Control FindControl(Controls controls, string controlName)
{
if (controls == null)
return null;
foreach (Control ctrl in controls)
{
if (ctrl.Name == controlName)
{
return ctrl;
}
else
{
Control c == FindControl(ctrl.Controls, controlName);
if (c != null)
{
return c;
}
}
}
} Then, you can call this using
picbox = FindControl(MyForm.Controls, nameToSearchFor) as PictureBox;
|
|
|
|
|
You want to find a control given its name?
Just do this.Controls["controlName"] and cast it back into a TextBox or whatever.
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
Hi
I am working on an application where i create a new group on local computer.
What i like to do is to give this group rights between user and poweruser
Eks: The user should open any application on the computer, but not be able to changes clock.
Is this possible
Thank you in advansed
Rune
|
|
|
|
|
Hi,
Does anyone know how I can remove a user control from a panel it has been added too, by a button on itself. Like an x button.
Cheers,
Chris
|
|
|
|
|
try by using Dispose() method.
Calin
|
|
|
|
|
Just guessing,
In the so called 'x' button's clickl
Button btn = sender as Button;<br />
UserControl u = btn.Parent as UserControl ;<br />
Panel p = u.Parent as Panel ;<br />
p .Controls.Remove(u);
(Assuming, Button is in UserControl and UserControl is in the Panel)
|
|
|
|
|
Thanks,
this worked perfectly
|
|
|
|
|
Hi
Perhaps you can created a Delegate in the User Control that when fired, will call a method in the parent form that can then remove the User Control.
I have not tried the code, but perhaps something like this:
In the User Control:
public event EventHandler RemoveSelf;
private void btnRemoveSelf_Click(object sender, EventArgs e)
{
try
{
if (RemoveSelf != null)
{
RemoveSelf(this, e);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
In the parent form:
private void Form_ Load(object sender, EventArgs e)
{
try
{
userControl1.UpdateData += new EventHandler(UC_ RemoveSelf);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void UC_RemoveSelf(object sender, EventArgs e)
{
try
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
As I said I have not tried it, but let me know if it works.
Regards.
Kobus
|
|
|
|
|
If I where you I should use events and delegates.
You make a delegate in your user control and when you click on the button you will call this.
An event in the parents control will catch this call. Because it is an event, you can give the user control as parameter. So you can do something like this:
-> loop through the panel
-> if the name from the 'sender' (which you cast to a control) is one in the panel
-> remove this one
|
|
|
|
|
Hi
I am having some problems with binding a TextBox to a data source. Actually the problem is in editing the data via the TextBox.
I am using Visual Studio 2005, C# and MS Access 2003 to develop a Windows Application.
On the Form I have the following controls:
DataGridView (name = dgv)
TextBox (name = txtWord)
BindingSource (name = bindingSource1)
DataSet (name = ds)
Button (name = btnSave)
I also have a class that I created to manage the data interaction. This class is called TestDataManager_MSAccess.
In this class I specify the table name of the relevant table in the database. (This is also the name that the DataTable will be called after the data loaded).
The class also has a load data method (TestDataManager_MSAccess.LoadTestData()) and a method to update the database (TestDataManager_MSAccess.UpdateDataTable()).
When the Form loads the data is loaded from the database and bound to the DataGridView via the BindingSource.
this.bindingSource1.DataSource = ds;
this.bindingSource1.DataMember = TestDataManager_MSAccess.TableName;
dgv.DataSource = bindingSource1;
I want the following to happen:
When the user double-clicks on a DataGridViewCell, the TextBox must be bound to the value in the DataGridViewRow. I bind the TextBox as follows:
private void dgv_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
dgv.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
dgv.EndEdit();
txtWord.DataBindings.Add("Text", this.bindingSource1, TestDataManager_MSAccess.Word_ColName);
}
This works ok and the relevant value in the DataGridViewCell is displayed in the TextBox.
But I also want to be able to edit the value via the TextBox, but it does not seem to work.
I look at the DataTable and even though the new value shows in the DataRow in the DataTable, the RowState still shows Unchanged. So when I call the Update method in my TestDataManager_MSAccess class the row will not update the database.
My code in the Form:
public Form_TxtBinding()
{
InitializeComponent();
}
private void Form_TxtBinding_Load(object sender, EventArgs e)
{
try
{
this.LoadDataController();
this.DisplayData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void LoadDataController()
{
try
{
if (ds == null)
{
ds = new DataSet();
}
this.LoadData();
}
catch (Exception e)
{
throw e;
}
}
private void LoadData()
{
try
{
string connectionString = Properties.Settings.Default.German_Genie_2ConnectionString;
TestDataManager_MSAccess.LoadTestData(connectionString, ds);
}
catch (Exception e)
{
throw e;
}
}
private void DisplayData()
{
try
{
if (ds == null)
{
return;
}
this.bindingSource1.DataSource = ds;
this.bindingSource1.DataMember = TestDataManager_MSAccess.TableName;
dgv.DataSource = bindingSource1;
}
catch (Exception e)
{
throw e;
}
}
private void dgv_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
dgv.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
dgv.EndEdit();
txtWord.DataBindings.Add("Text", this.bindingSource1, TestDataManager_MSAccess.Word_ColName);
}
private void UpdateDatabase()
{
try
{
if (ds.HasChanges() == true)
{
this.dgv.EndEdit();
string connString = Properties.Settings.Default.German_Genie_2ConnectionString;
TestDataManager_MSAccess.UpdateDataTable(connString, ds.Tables[TestDataManager_MSAccess.TableName]);
}
}
catch (Exception ex)
{
throw ex;
}
}
private void btnSave_Click(object sender, EventArgs e)
{
try
{
this.UpdateDatabase();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == -1)
{
dgv.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
dgv.EndEdit();
}
else if (e.RowIndex == -1)
{
dgv.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
dgv.EndEdit();
}
else
{
dgv.EditMode = DataGridViewEditMode.EditOnEnter;
}
}
I can edit the data from within the DataGridView and update the database, but I would like to be able to edit the data in this way as well, because I find if you have a DataGridView with many DataGridViewComboBoxColumns and data formatting, the performance is very much affected. So for those types of situations I would like to be able to select the DataGridViewCell and the values from the row must be bound to other controls (like TextBoxes) and the user must be able to edit the values on those controls.
Am I missing something in the binding of the TextBox to a data source?
Thanks.
Kobus
|
|
|
|
|
Hi Guys. I would like to know the correct way of stopping a Thread and how I can close the current Excel workbook. In My application I am reading a text file and writing the details from there to an Excel workbook. Problem that I have is that I would like to add a "STOP" button to the application. In my stop button even I have the following code.
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Process aborted by user", "Process Abort Message",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
Thread.CurrentThread.Abort();
}
Now, I have found that Thread.CurrentThread.Abort() closses the application, Aborting it, but it doesn't close the Excel workbook that was opened by the Thread. How do I close the workbook? I suppose I need to close it in this button event but how do I do that as the Thread.CurrentThread.Abort() closses the application completely.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
You shouldn't terminate the application in such an abrupt manner, NEVER!!
Before you terminate you need to make sure you release all handles/resources gracefully(in this case the Excel workbook) and also that your application has left the data in a stable state.
If your application is having to write the excel while you call the Abort then you should notify the method that has currently opened the excel sheet to close it as the application will be terminating Or disable the button(button1) while the excel operation is being done.
Bottomline, make sure you complete\rollback all changes and close the excel workbook gracefully before you terminate the application.
|
|
|
|
|
I found some articles here on Code Project describing how to get the classic "Open With" dialog in C#. This gives me a dialog that lets me choose an application to open a specified file with, and then opens the file in the chosen editor.
I would like to have the dialog as it is, but instead of opening the application I would like to be able to get the location of the executable on disk. This information will be saved in my application for later use.
All ideas are welcome, thanks in advance!
/Martin
|
|
|
|
|
Hello,
I want to create a windows service application that listen to changes in a SQL server database then sends all these changes to an other server waiting for the server response.
Can i use the sql service notification service to restart the windows service after each change in the database and how? or there is adicect solution fron the database itself?
Thanks for advance.
Dad
|
|
|
|