|
AFAIK it would be enormously difficult to put a gridview in a listview.
Why not simply use a DataGridView?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Henry,
Thanks for your reply. Using the DataGridView was always one the options that I had. Maybe its time that I zeroed-in on using the DataGridView...
Thanks,
ramz_g
|
|
|
|
|
I have the following code:
string name = "c:\\1.flv";
axShockwaveFlash1.Movie = name;
axShockwaveFlash1.Play();
And there is no playback. But when I try playing some swf file - everything is OK.
What am I misising?
Thanks.
modified on Thursday, May 14, 2009 12:32 AM
|
|
|
|
|
Are you absolutely sure it's a Flash Video file?? Does it play in a web browser??
|
|
|
|
|
100%. I've played it with FLV video player.
|
|
|
|
|
hello
is it possible to bakcup a database at a server and restore it at an otehr one?
if yes,thanks to give me some ideas
|
|
|
|
|
Yes - assuming SQL Server
Backup to a file using management studio
copy file to different server
restore database using management studio
Depending on the database/version you may need to create the database before you can restore into it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Assuming you're using Sql Server Management Studio...
Right click the db you want to copy -> Tasks -> Back Up
Give the backup set a name (with .bak extension) and add a destination to save it to disk
Copy the backup to another server then Right Click the Databases node -> Restore Database
Add a name for the new db into the To database field and then select the From device radio button. Select your backup file and click the Restore tick box and then click OK.
This will copy the database to the new server.
|
|
|
|
|
I have several PictureBox Controls in my Form. I want to change the Image property of one of them depending on its Tag property. This is my code:
<br />
foreach(Control ctrl in this.controls)<br />
{<br />
if(ctrl.GetType().ToString() == "System.Windows.Form.PictureBox")<br />
{<br />
System.Windows.Form.PictureBox temPic = (System.Windows.Form.PictureBox)ctrl;<br />
if(tempPic.Tag="1")<br />
{<br />
tempPic.Image = someImg;
ctrl = tempPic;<br />
}<br />
}<br />
}<br />
Doing this I get an error:
<br />
Cannot assign to 'ctrl' because it is a 'foreach iteration variable'<br />
Is there any workaround for this or any ideas in order to achive this goal?
Any help would be apreciated
Ivan
|
|
|
|
|
Hi,
your code doesn't make much sense:
1.
the statement ctrl = tempPic; would do no good since tempPic already equals ctrl due to a previous assignment.
2.
why set a new value to ctrl, it is not used anywhere. (if you were to use PRE tags, see the "code block" button, you would have preserved the formatting of your code, making things much easier to read and understand).
BTW1: if(ctrl.GetType().ToString() == "System.Windows.Form.PictureBox")... is horrible; what you probably want is: if (ctrl is PictureBox)... or the "as" keyword (see below).
BTW2: your code will not compile, e.g. this.controls and ...Tag="1" are wrong
Maybe this is what you want overall:
foreach(Control ctrl in Controls) {
PictureBox pb=ctrl as PictureBox;
if(pb!=null && pb.Tag=="1") pb.Image=someImg;
}
I would like to suggest you buy a tutorial book on C# and study it; that will teach you all the basics in a structured and logical way, explaining the rationale and providing good examples.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
You left nothing for him
Sincerely Samer Abu Rabie
Imagination is more important than knowledge !
|
|
|
|
|
In this application I am playing with, I am generating a tabcontrol on the fly where each tab is a folder name in a directory. I am then dynamically adding a new DataGridView onto the new tab that was created and listing out the files inside of this directory (there are no sub directorys which is the reason I am doing it this way). This is all working file exactly like what I want except I can not figure out how to build a dynamic onrow click event because I have no idea how many tabs the application will have in the future. Can someone point me in the correct direction?
Listed below is the code that is looped through when adding the dataGrid to each tab (notice the name has the tabIndex).
DataGridView dataGridTicketInformation = new System.Windows.Forms.DataGridView();
dataGridTicketInformation.Name = "dataGridView" + tabIndex.ToString();
dataGridTicketInformation.Size = new System.Drawing.Size(401, 201);
// First we need to add a column
dataGridTicketInformation.Columns.Clear();
dataGridTicketInformation.Columns.Add("Name", "Name");
dataGridTicketInformation.Columns[0].Width = 301;
dataGridTicketInformation.Columns.Add("Data", "Data");
dataGridTicketInformation.Columns[1].Width = 100;
// Clear all the old Data first
dataGridTicketInformation.Rows.Clear();
|
|
|
|
|
I'm assuming you know how to add an event to the datagridviw
this.dataGridTicketInformation.DoubleClick += new System.EventHandler(this.GenericGridEvent);
GenericGridEvent would deal with the DGV getting the identity from the sender object
There is no RowClick event on the DGV, pick one of the other events to add.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If I have correctly understood what it is that you want to do.
Create a RowHeaderMouseClick event handler like this (I assume that this is the handler you want)
private void DataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
DataGridView dgv = (DataGridView(sender;
dgv.CurrentRow.Cells["Name"].Value = "Fred";
}
The same principle applies to any handler for multiple controls.
Then in the code that you posted, I dont think it matters where as long as it is after instantiation:
dataGridTicketInformation.RowHeaderClick += DataGridView_RowHeaderMouseClick;
BTW if the grid is disposed befor closing the app by using:
dataGridTicketInformation.RowHeaderClick -= DataGridView_RowHeaderMouseClick;
Hope this helps.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Do you need to dispose of the event explicitly?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have had problems in the past that although I never managed to track down the exact cause, disappeared after doing so, so I always do now. I think it is recommended somewhere in MSDN too.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I am starting to use the 1 event for lots of controls, in VB you could just add the control to the Handle list, for things like turning the save button on after a value is edited, the event does not care about the sender just turns on the save button.
I presume I should dispose each event on each control when leaving the form!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I presume I should dispose each event on each control when leaving the form!
If the Form will be Closed (i.e. Disposed) then it is not necessary.
Where I have used this method is for dynamically created controls, such as described by the OP. Where these controls are disposed but their parent control/form is still live, I detach the event handler.
I think the reasoning is that there will still be a reference to the disposed control, although convoluted, via the events mechanism. This will prevent it being Garbage Collected.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Im just not able to get this going, so hopefully you can help. The error I am getting is Method Name expected on "dataGridTicketInformation, new CustomRowEventArgs(dataGridTicketInformation"
I first specify the CustomRowEventArgs and the DoubleClick function
public class CustomRowEventArgs : EventArgs
{
DataGridView grid;
public DataGridView Grid
{
get { return grid; }
}
public CustomRowEventArgs(DataGridView dgv)
{
grid = dgv;
}
}
private void dataGridTicketInformation_DoubleClick(object sender, CustomRowEventArgs e)
{
MessageBox.Show("DoubleClick Sent");
}
Then after I dynamically build and load all the information into the datagrid I call the doubleclick function
dataGridTicketInformation.DoubleClick += new System.EventHandler(dataGridTicketInformation, new CustomRowEventArgs(dataGridTicketInformation));
|
|
|
|
|
OK.
This line:
dataGridTicketInformation.DoubleClick += new System.EventHandler(dataGridTicketInformation, new CustomRowEventArgs(dataGridTicketInformation));
should be:
dataGridTicketInformation.DoubleClick += new System.EventHandler(dataGridTicketInformation);
***** See below for where to put it
and it is not used to call the doubleclick function it is used to link each DataGridView with the dataGridTicketInformation_DoubleClick method you have written, so that when you doubleclick on any of your grids you will get your "DoubleClick Sent" messageBox. It should be part of the creation of each DataGridView the line should go
DataGridView dataGridTicketInformation = new System.Windows.Forms.DataGridView();
dataGridTicketInformation.Name = "dataGridView" + tabIndex.ToString();
dataGridTicketInformation.Size = new System.Drawing.Size(401, 201);
dataGridTicketInformation.Columns.Clear();
dataGridTicketInformation.Columns.Add("Name", "Name");
dataGridTicketInformation.Columns[0].Width = 301;
dataGridTicketInformation.Columns.Add("Data", "Data");
dataGridTicketInformation.Columns[1].Width = 100;
dataGridTicketInformation.Rows.Clear();
dataGridTicketInformation.DoubleClick += new System.EventHandler(dataGridTicketInformation);
Unless there is a need to pass some special data on double click the CustomRowEventArgs is not needed. Even if this need exists, I would concentrate on getting the plain old doubleclick functionality working first, so that you can get an understanding of how it works.
Make a separate post if you need help in implementing a CustomRowEventArgs.
Assuming that you do this, all that needs to happen for the doubleclick action to be triggered is for you to double-click any of the dataGridTicketInformation instances that your app creates at run-time.
When you get it working with your messageBox version of dataGridTicketInformation_DoubleClick , it is important that you use the
DataGridView dgv = (DataGridView)sender;
method I showed earlier, otherwise you will not be able to tell which dataGridTicketInformation made the call.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
If I add that code I get a error on the EventHandler ('dataGridTicketInformation' is a 'variable' but is used like a 'method'). Any ideas?
dataGridTicketInformation.DoubleClick += new System.EventHandler(dataGridTicketInformation);
|
|
|
|
|
Sorry! My bad, over-eager with the cut and paste.
Should be
dataGridTicketInformation.DoubleClick += new System.EventHandler(dataGridTicketInformation_DoubleClick);
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi.
How can we write a program for a Core 2 due CPU ?
I mean, a program that divides the process between cores !
Thanks
|
|
|
|
|
|
You can use multi-threading, but realize that the OS itself and the internal operations of .NET are already doing that. Also be aware that multi-threading for the sake of multi-threading may add complexity for no reason and cause your program to actually run slower.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|