|
DataGridViewCell is an abstract class. Thus, you cannot create an instance. However, you can do the following:
// dataGridView1 has two columns: Name and Age.
// At this point dataGridView1 does not have any rows or cells
DataGridViewRow^ row = gcnew DataGridViewRow;
row->CreateCells(dataGridView1);
dataGridView1->Rows->Add(row);
dataGridView1->Rows[0]->Cells[0]->Value = "George";
dataGridView1->Rows[0]->Cells[1]->Value = "54";
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George,
This isn't working for me too well. I keep getting array bounding errors. Your example is much like what I have seen where you start with some number of colums but no rows or cells. What I have done is pre-define the number of rows and columns like this...
dataGridView1->RowCount = 150;
dataGridView1->ColumnCount = 120;
myArray = gcnew array<celllocation^, 2="">(dataGridView1->RowCount, dataGridView1->ColumnCount);
for(int i = 0; i < dataGridView1->RowCount; i++)
for(int j = 0; j < dataGridView1->ColumnCount; j++)
{
dataGridView1->Columns[j]->Width = 8;
dataGridView1->Rows[i]->Height = 6;
}
This code will display a 120 column by 150 column grid (although it does take 10 seconds to display) which is what I want, but how do I navigate it? It would be intuitive to do something like...
dataGridView1(cell_row_value, cell_cloumn_value) = what goes into the cell
but that doesn't work. It seems I have to use the Cell->Value property but I have to set the (row, col) coordinates of the cell and I can only set the coordinates with a DataGridViewCell^ data type and I can't instantiate a DataGridViewCell^ because it's abstract. I can't figure out how to say 'Make the current cell the cell at row coordinate X and column coordinate Y'. This is what I need to know.
Thanks
Buck
|
|
|
|
|
Buck,
In your original post, you did not give enough information to warant a specific answer to your current needs. However, see if this may work:
for (int i = 0; i < 120; ++i)
{
DataGridViewTextBoxColumn^ col =
gcnew DataGridViewTextBoxColumn;
col->Name = "col" + i.ToString();
col->HeaderText = i.ToString();
dataGridView1->Columns->Add(col);
}
for (int i = 0; i < 100; ++i)
{
DataGridViewRow^ row =
gcnew DataGridViewRow;
dataGridView1->Rows->Add(row);
}
dataGridView1->Rows[9]->Cells[4]->Value = "George";
There may be a faster way of doing this, and I will dig a little deeper. I don't do much Window Forms programming.
-- modified at 18:32 Thursday 20th September, 2007
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George,
Oh by the way, when I click on the close button in the top right most corner of the form that contains the DataGridView conrol it takes the same amount of time to exit the form as it does to display it (ten seconds).
Buck
|
|
|
|
|
Reading the documentation, I came up with this:
for (int i = 0; i < 120; ++i)
{
DataGridViewTextBoxColumn^ col =
gcnew DataGridViewTextBoxColumn;
col->Name = "col" + i.ToString();
col->HeaderText = i.ToString();
dataGridView1->Columns->Add(col);
}
dataGridView1->Rows->Add(100);
dataGridView1[3, 9]->Value = "Buck";
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi All,
I want to insert smiley faces in the Rich Edit Control (like Yahoo Chat)...can anyone help me in this issue..
just tell me how to load the smiley and display it in the Rich Edit control.
Thanks in advance,
Shiva
|
|
|
|
|
If you had used google, you would have found at least two articles:
http://www.codeproject.com/cs/miscctrl/csexrichtextbox.asp
http://www.codeproject.com/cs/miscctrl/MyExtRichTextBox.asp
|
|
|
|
|
hi,
I'm working in .NET 1.1 and I've been given an application built in MFC and I need to generate some XML log files. I wanna use the XMLtextwriter class but as far as I see it, it doesnt allow you to add a namespace suchas
using namespace System::Xml;
So what should I do?? is there some way I can use the XmlTextWriter class in an MFC application?
Thanks in advance
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
|
XmlLite is looking like some thing quite helpful I'm exploring it nnow.. lets see what happens then,
thanks again George!
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
well I've downloaded and installed the XmlLite upgrade for WinXp and I've also seen the info abt using Xmllite over MSDN online. The problem I'm facing now is that all the samples given over there are for VS 2005 whereas I'm using VS 2003 and I tried to run the sample but its not getting the 'xmllite.h' file. I've searched for it but its no where to be found!! but the interesting thing is that xmllite.dll is there in the System32 directory.
All I wanna do is to use the IXmlWriter Interface to write the XML document. but HOW DO I DO IT IN VS2003?? Thats the big question???
Any suggestions??, samples?
Thanks
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
well I just found the answer myself , Its the Windows SDK for Vista! Thats what I need. and its 1187.5MB
Why in the world do i have to download the whole thing just to use xmllite.lib and .h files??
Isnt there anyway I can do the work with downloading this whole thing?
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Hi,
Let suppose, there is an exe file and it has a certain output at console. Is it possible to read that console output anyway?
I would appreciate the suggestions.
Wali
|
|
|
|
|
Please don't cross-post. Posting your question in the appropriate forum is sufficient.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Why you asked this question again on this forum?
|
|
|
|
|
|
Hi, I am using Visual Studio 2005 C++/CLI. I posted this before with no responses so maybe no one knows. I want to use an existing Form from another project (I don't want to recreate the 50 controls on the Form). I can include the Form into my project but if I then try to modify the Form from the Solution Explorer by right clicking on the form name and selecting 'View Designer', I can't because this option is not available to me like it is with the Forms that I created in this project. Can Forms AND their design views be copied from one project to another?
Thanks
Buck
|
|
|
|
|
What you are talking about may be possible but it might be better asked in a Visual Studio forum since your question deals more with a VS feature. IMHO, the relationship between C++/CLI and the View Designer can be broken with little effort.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks for the reply, I will check that out.
Buck
|
|
|
|
|
Hi Buck,
I see two approaches that should work:
if the form you want to copy is the only form in its project (or constitutes the majority of
the existing project), I would use Windows Explorer and duplicate the entire folder containing
project, source files, and resources; then choose a new folder name and open the copied
project, modifying what needs to be changed, and adding what you want to add.
if the form you want to copy is to become something other than the main form of an
existing project, I would simply copy all the related files (myform.cs, myform.Designer.cs,
myform.resx) to the new projects folder, then add these "existing items" to the project,
then modify what needs to be modified.
Whatever approach you choose, if you want to rename the form's class and/or the form's
file name(s), I would do it using Visual, not in Explorer nor by editing the project files.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc,
Luc Pattyn wrote: would simply copy all the related files (myform.cs, myform.Designer.cs,
myform.resx) to the new projects folder
You must have C# on your mind!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Sure, but then I figure C++ can't be lagging that much
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
The designers in C++/CLI are one or more version behind C#. In .NET 1.0, there was no Windows Forms Designer. If you change the name of the form's class without making other manual changes, the designer will cease to work.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George,
I was not aware of that, but then I don't use C++ very much.
Thanks for the info.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|