|
hello!
I have 2 problems with a comboBox and a dataGrid.
The first problem is that when i'm selecting a table from the comboBox it's ok, but when i select the second or the third table it's not very good. I have too many lines and columms remaining from the first selected table...i must clear that table or datagrid.
The second problem ... i want that my selected table fit in the dataGrid.
This is my code:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
alege_tabel = comboBox1.SelectedItem.ToString();
dataSet1.Clear();
SqlCommand sel = new SqlCommand();
sqlDataAdapter1.SelectCommand = sel;
sel.Connection = this.sqlConnection1;
if (alege_tabel == "Oferte")
{
dataSet1.Clear();
sqlDataAdapter1.SelectCommand.CommandText = "select * from Oferte";
sqlDataAdapter1.Fill(dataSet1);
dataGrid1.SetDataBinding(dataSet1, dataSet1.Tables[0].TableName);
}
if (alege_tabel == "Locatie")
{
dataSet1.Clear();
sqlDataAdapter1.SelectCommand.CommandText = "select * from Locatie";
sqlDataAdapter1.Fill(dataSet1);
dataGrid1.SetDataBinding(dataSet1, dataSet1.Tables[0].TableName);
}
if (alege_tabel == "Transport")
{
dataSet1.Clear();
sqlDataAdapter1.SelectCommand.CommandText = "select * from Transport";
sqlDataAdapter1.Fill(dataSet1);
dataGrid1.SetDataBinding(dataSet1, dataSet1.Tables[0].TableName);
}
if (alege_tabel == "Rezervari")
{
dataSet1.Clear();
sqlDataAdapter1.SelectCommand.CommandText = "select * from Rezervari";
sqlDataAdapter1.Fill(dataSet1);
dataGrid1.SetDataBinding(dataSet1, dataSet1.Tables[0].TableName);
}
}
|
|
|
|
|
i wrote this code in Class Librery
DirectoryInfo GetPath = new DirectoryInfo("MD.DAT");
string Path = GetPath.FullName;
this code back the path of the MD.DAT file
but if i use a openfiledialog befor i call this code
it back the path of the openfiledialog
how can i soleve this problem
MD_NADA
|
|
|
|
|
Without seeing your code it is difficult to help you out, but I am guessing that you are setting your Path variable when the openfiledialog returns.
Note you can also use FileInfo to get the path of a file.
Ben
|
|
|
|
|
Hi,
when you specify a relative file (a partial name) the "current directory" gets involved.
This CD may get changed in many ways, e.g. by showing an OpenFileDialog,
SaveFileDialog, ...
It depends on their RestoreDirectory property (which modified the behavior the
second time you show such a dialog).
|
|
|
|
|
hi
in my windows based application i need to export data from grid to excel,word. iam very new to c#.net.please kindly help me.
|
|
|
|
|
hi,
you can use Excel API for that purpose.
Just include Microsoft Excel component in your project's reference and you will be able to use Application.Excel component.
Manoj
Never Gives up
|
|
|
|
|
Hy,
I have a problem with an Open File Dialog. When I press the browse button I open an Open File Dialog.I try to make a folder...an I can make it.And If I try to delete it my program crashing with message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
Can someone to help me with some idea?
Can I put a restriction to only selection without changes in my Open File Dialog?
10x
|
|
|
|
|
I added elements to hashtable but they are not in the order in which i added. The code is below:
Hashtable table = new Hashtable(4);
table[new Regex(@"^(-?)(\d*?)\.?(\d{0,1})?$")] = "$1$2.$3";
table[new Regex(@"^(\d*?)\.?(\d{0,1})?(-?)$")] = "$3$1.$2";
table[new Regex(@"^(-?)(\d{1,3}?)((?:,\d{3})*)\.?(\d{0,1})?$")] = "$1$2$3.$4";
table[new Regex(@"^(\d{1,3}?)((?:,\d{3})*)\.?(\d{0,1})?(-?)$")] = "$4$1$2.$3";
I want these elements in the same order. Some times it takes the same order and some times it does not. I know hashtable does not take elements in same order.
But is there a way for this?
|
|
|
|
|
Yes, this is an effect of hash tables.
"Realize that the order with which the items are inserted and the order of the keys in the Keys collection are not necessarily the same. The ordering of the Keys collection is based on the slot the key's item was stored."
ref from: http://msdn2.microsoft.com/en-us/library/aa289149(VS.71).aspx[^]
If you don't like this behavior then don't use a hash table.
|
|
|
|
|
|
You could also try SortedList. It's not as efficient as Hashtable but may not matter for you if you only have a few entries.
Kevin
|
|
|
|
|
I am using a picture box to display a number of points on the screen. My problem is that I dont know how to resize the picture so I can see the points on all the picture box and not only in one part of the picture box.
|
|
|
|
|
Hello there! I've been trying, without any luck for the past week or so to get the "currently playing" movie/song in my Windows Media Player.
I know I need to use SendMessage to send and receive info from WMP. I've managed to write Play/Pause/Stop methods:
Example:
---
// stop WMP movie/song
IntPtr ptrWindow = FindWindow("WMPlayerApp", "Windows Media Player");
if (ptrWindow == IntPtr.Zero)
return;
SendMessage(ptrWindow, WM_COMMAND, 0x00004979, 0x00000000);
---
However, this doesn't get me anywhere near the "Currently Playing" movie/song. I've looked into the WMP SDK, but that doesn't seem to help. I don't want to make a new instance of WMP. I want to read the currently playing info from my own WMP app that's open.
I'd appreciate any help in getting closer to what I need.
Thanks in advance.
|
|
|
|
|
The playing item could be found in:
WMP.currentMedia.name
Heino
|
|
|
|
|
Thank u for your reply!!
how can i appoint this Object?
please give me an example?
|
|
|
|
|
You must have AxWMPLib in your reference of your C#-project.
Then you have to add the Mediaplayer as a control to your form.
For instance, name the control to "WMP".
After that you can do.
WMP.URL = "the musicfile full path";
string cName = WMP.currentMedia.name;
Heino
|
|
|
|
|
I triedto execute a notepad application in windows services using
1. System.Diagnostics.Process.start("notepad.exe")
2. System.Diagnostics.Process process1 =new System.Diagnostics.Process();
process1.StartInfo = new ProcessStartInfo("NOTEPAD.EXE");
process1.Start();
and by giving full path also i.e "c:\windows\notepad.exe"
But the application is not started and it is not showing error also.
Could you please give a suggestion.
Please it is very urgent.
And I want to know how to get the acknowledgment from the process that i has been executed successfully.
-- modified at 7:31 Saturday 26th May, 2007
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
I have a question. Why would you want to do this? The purpose of a windows service is that it is running as a set user that you define in the login tab. This allows the windows service to run all the time not just when someone is logged into the computer. Ok that being said.
I would guess that you are running your windows service with a login that doesn't have rights to open notepad, or that the window service perhaps is not running. The way you are going about trying to open note pad should work fine. Perhaps you should check the event log to see if any errors are getting logged. You could also do some event logging in your windows service. You also might want to put a try catch around the call to your process to open notepad, you might be getting an exception.
Hope that helps.
Ben
|
|
|
|
|
By chance I've come across this problem some time ago, too.
I wanted to create a service that's listening for PowerEvent and SessionChange events (suspend/resume windows) and executes applications in a given directory (similar to Autostart, but being executed even when the computer is restarted from suspend mode.
Unfortunately, I couldn't get it to work, no matter what I tried.
I could get the service to start the applications, but the application windows didn't show. Neither UseShellExecute=true nor UseShellExecute=false made any difference.
I couldn't find out why and the project was forgotten after a while...
So if anyone can help I'd be interested as well.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
This is what M. J. Jaya Chitra found:
Thanks for your reply.
I am having sufficient privileges.
Now I got the answer, I have checked the option 'interact with desktop' in the 'Log on' tab in the service properties window.
But this leads to another question, this is done manually is there any provision to change this property while designing the service itself
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Thanks for your reply.
I am having sufficient privileges.
Now I got the answer, I have checked the option 'interact with desktop' in the 'Log on' tab in the service properties window.
But this leads to another question, this is done manually is there any provision to change this property while designing the service itself
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
I don't know any way of doing it, but that doesn't mean it can't be done. If you search through the ProcessInstaller you may find a property that would install the service as checked.
Ben
|
|
|
|
|
I created a custom control which simply is a data-bound ComboBox . It has a custom property that causes an ArrayList of KeyValuePair elements to be passed to the DataSource property. It also sets the DisplayMember and ValueMember properties.
What's weird, is the fact that my control sometimes works fine and sometimes it doesn't. I have no idea why, but when I put on Form1 everything is fine, while on Form2 the Items collection stays empty, although the DataSource property contains data and it is exactly the same data (pulled from the database in the same way) that I use in case of Form1 .
I tried to use a DataTable instead of an ArrayList , but it changed nothing.
Does anybody have any suggestions?
|
|
|
|
|
I found a solution.
It seems that the problem was caused by the fact that in one the windows (Form2 ) I was trying to access the Items collection in the window's constructor. Even though I put my code after the InitializeComponent method, the combo box must've been still not fully initialized. I moved the code to Form.Load event and everything works fine.
|
|
|
|
|
Hi
Does anyone have a tip about a nice C#-control for volumesettings ?
The common trackbar will do, but i need one where i can set Backcolor to Transparent, and the standard trackbar does not accept that.
Any tips ?
With Kind Regards
Heino
|
|
|
|