|
Also, please do not cross-post questions.
|
|
|
|
|
hi , could someone please help me out with the datagridviewer? i'm new to C# , dont have much of any idea about it. i'm building a booking program for a little hotel.
I need :
1. to have a context menu thats cell specific , i know i can use the datagrid contextmenu prop. or handle the cellcontextmenuneeded event , but if i right click on a cell the focus does'nt change to that cell , i have options on the menu that pertain to single cells like excel.
2. How do i restrict the user from adding new rows or deleting existing rows , but he should still be able to edit the text in the cells.
3. i have two tables , one is a status table with status for all rooms .. it has 2 cols. roomID and customerName. The second table is a customers table with all the cutomers details and customerName. Now the customerName col. in both the tables should be related , the datagridview has 25 rows each for a room , it should scan the status table for each room , and load the corresponding customers details into the datagridview. How do i make a relation and do the above?
i need this a little quick so please help!
Thanks in advance
Gideon
|
|
|
|
|
1 - it's a little tricky, give me some time to think about it.
2 - in the smart tag of the datagridview, uncheck "enable adding" option
3 - a binding source could help you.
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
hey , i got it!
i dont know much but it works perfect this way:
<br />
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)<br />
{<br />
dataGridView1.CurrentCell = DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];<br />
this.dataGridView1.ContextMenuStrip = this.contextMenuStrip1;<br />
}
works only on this event ... and yes the contextStrip shows up when i right click . not when i left click
thanks so much for your concern!
but i got another problem now.. .basically.. .the datagrid on my form shoud display the status of ALL the rooms... for a given date(i have a datepicker on the form) .. ok so now in my test app. when i hit 8th on the datepicker , the DGV shows one entry .. room 103A is booked on that date. Problem is , it only shows one entry .. i want the empty rooms to show up as empty rows. I know i have to add unbound data. I tried to add blank rows. but its says i cannot add anythign programmatically if i have it bound.
If its unbound this is how i add the rows ..
DataRow dt = dataSet.Tables["customers"].Rows[0];<br />
dataGridView2.Rows.Add(dt[0] , dt[1] , dt[2] ....... );
is the above correct or is there a better way...??
also if i add the blank rows .. and the user adds something in it what event do i have to handle? and how do i update/add the DB manually? i know SQL .. i'm using oledb . for an access database (.mdb)
now one of the colums inthe database is roomtype. but then when i load the values i want them in a combobox? how do i do that? how do i adda combobox to the DVG?
DataGridViewComboBoxColumn cboColumn = new DataGridViewComboBoxColumn();<br />
cboColumn.Items.Add("a");<br />
cboColumn.Items.Add("b");<br />
dataGridView2.Rows.Add("", cboColumn, "");
i get -> DataGridViewComboBoxColumn { Name=, Index=-1 } in the second column!
plz help!
|
|
|
|
|
We're developing an application (.net 2.0 / C#) that interacts with Office and other external applications. So all needed references are added to Visual Studio's "References" and then used ("using x.y.z") in our sources.
This works fine but what if someone (an enduser) doesn't have say MS Project installed?
The sources won't compile, crying that "The type or namespace 'MSProject' does not exist ... (are you missing an assembly reference?)".
Is there any possibility to make a (prior) test if a reference is available or not? Something like a try/catch surrounding the "using" statement?
In fact we would like to test if MS Project (or another application) is installed and if not simply don't provide the functionality. I searched on MSDN, Google Groups, etc but did not find something useful...
Thank you very much for your help!
|
|
|
|
|
Maercu wrote: what if someone (an enduser) doesn't have say MS Project installed?
The sources won't compile,
Why would an "end user" be compiling?
Maercu wrote: In fact we would like to test if MS Project (or another application) is installed and if not simply don't provide the functionality. I searched on MSDN, Google Groups, etc but did not find something useful...
Take a clean machine and save the registry. Install MS Project and save the registry to another file. Do a DIFF on the two files.
led mike
|
|
|
|
|
What happens when you compile evertything with the references working and then put it on a machine without the office programs? It should throw an exception when you try to create an object based on the references. Examine the description for that and you should be able to then do try->catch on startup to tell what is installed.
Assert(this);
|
|
|
|
|
OK thanks for your help so far.
Another idea: Would it be a better idea to integrate/import the DLL(s) during run-time? So rather than including them via Visual Studio's "References" to include them directly in the classes that need them?
I imagine that this way compiling would always be fine and that the statement could be put inside a try/catch structure so catching the situation when a DLL isn't available would be easier...
Do you have any suggestions how this could be done?
Thanks a lot!
|
|
|
|
|
Hello,
I am a new user of this forum. I need some advice. In System.Net.Sockets namespace there are two class, NetworkStream and Socket Classes and in System.IO there is Stream class for using TCP/IP connection between server and clients. I have read their members, properties and events in MSDN, they are nearly the same but I wonder there are any advantages or disadvantages between them. For my program which class should I use? I use TCP/IP and DNP (Distributed Network Protocol) for my application, some devices connected to LAN sends data to my application also my application can send commands to these devices. But I can not decide which class do I use.
|
|
|
|
|
Hi all.
I have a problem...
On one PC this code: DateTime _dateTimeNew = Convert.ToDateTime(_date + " " + _time); works fine as it returns the _dateTimeNew with the value '11/6/2006 4:00 PM' but on my PC the _dateTimeNew value is '11/6/2006'
in this example the date is '11/6/2006' and the time is '4:00 PM'
Sorry, i know this is a difficult one...
Please help.
Regrds
Nico
-- modified at 10:34 Monday 6th November, 2006
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Have you run it through the debugger, and checked the values of the variables? You also want to check handling your date a little differently. It seems like the _date and _time can be handled in a different way.
|
|
|
|
|
Yes i've tried that. i even assigned the whole value '11/6/2006 4:00 PM' to a string Variable called _test and did it like so...
string _test = _date + " " + _time;<br />
DateTime _dateTimeNew = Convert.ToDateTime(_test);
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Take a look at the culture for them. Convert.ToDateTime on strings uses the current culture. If you want to force it into a particular format, use an IFormatProvider to force it into a specific culture.
CultureInfo culture = new CultureInfo("en-GB");<br />
<br />
string dateTime = Convert.ToDateTime(_date + " " + _time, culture);
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
oh sorry, i modified my code now...
it was supposed to say DateTime _dateTimeNew = Convert.ToDateTime(_date + " " _time)
This is how it is in our code... yet it throws away the _time variable's value and the _dateTimeNew Variable only gets the '11/6/2006' part not the whole '11/6/2006 4:00 PM'
It really has me boggled.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Still - take a look at the CurrentCulture. Remember, the input to the Convert is the string, so this is dependent on the culture.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks, i'll try that. The thing that i can't get is why it would work on one pc and not on the other...
But thanks i'll try it your way...
Thank you for your time.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Because the culture is set differently on each machine.
|
|
|
|
|
no, it's the same... we checked the regional settings if that is what you mean by culture being different.
Still, this problem is still a problem...
Thank you for taking time to help.
Enjoy your day...
Regards
Nico
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hi Guys!
I'm trying to build an application that will allow a user to enter some information into a number of boxes on a Windows Form, which will then be entered into a HTML page, which will then be converted into a PDF.
The info entered will be:
Heading 1
Info 1
Price 1
Heading 2
Info 2
Price 2
...etc
This should then be added into the correct places in an HTML document.
The user never really needs to see this HTML page but it is the only way I can think of getting the correct layout with images etc. that will be needed for the PDF.
This should then be converted into PDF.
If someone can please help with the first part of this problem, and then we can all work through the next stages when applicable?!
Thanks!!
Dave Hunter
|
|
|
|
|
Hi, Dave.
I did some pdf generation on www.DownloadAClue.com[^], but I didn't use HTML as an intermediate step. Instead, I found a PDF library and basically coded the layout for the files.
Do you have a specific need for the interim step, or is it just a matter of trying to avoid laying out the pdf manually?
|
|
|
|
|
Hi,
Trying to read the data from an excel spreadsheet in C# 2005, but there is an error as follows:
The Microsoft Jet database engine could not find the object 'Cities$'. Make sure the object exists and that you spell its name and the path name correctly.
The excel speadsheet is placed in the same place as Program.cs and the sheet name is indeed cities.
This is the code:
private void btnExcel_Click(object sender, EventArgs e)
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
using (DbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = connectionString;
using (DbCommand command = connection.CreateCommand())
{
// Cities$ comes from the name of the worksheet
command.CommandText = "SELECT ID,City,State FROM [Cities$]";
connection.Open();
using (DbDataReader dr = command.ExecuteReader()) //fails here...
{
while (dr.Read())
{
Console.WriteLine(dr["ID"].ToString());
}
}
}
}
}
|
|
|
|
|
Are you sure the page has the same name?
|
|
|
|
|
When I open the file Book1.xls, the sheet name is Cities whereas in the select query I am using [Cities$]. used Cities instead but no change.
|
|
|
|
|
fmardani wrote: The excel speadsheet is placed in the same place as Program.cs
The Book1.xls needs to be in the same directory as your .exe. Place the Book1.xls file in the \bin\Debug directory if you are debugging and in \bin\Release if you are running in release mode.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hi...
I want to use FIFO queue concept for PC serial port communication through PC com port for data transmission & reception.
Can anybody suggest me any good document available on net for this or any suggestion how i can use it in my application...?
Thanks,
Vinay
|
|
|
|