|
Hi,
Please consider the following interface in C++.Net
public __interface IAnimal<br />
{<br />
void Eat(String^ food);<br />
};<br />
when I try to implement this in a C# class...
class Dog : IAnimal<br />
{<br />
...<br />
}<br />
It gives me an error "error CS0509: 'Dog': cannot derive from sealed type 'IAnimal'"
What am I doing wrong here?
SDX2000
SDX2000
|
|
|
|
|
Don't you want a managed C++ interface class instead?
public interface class IAnimal<br />
{...<br />
<br />
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for pointing this out. I have used C++ and C# but I am new to C++/CLI. This works as desired.
SDX2000
|
|
|
|
|
Hi All..
I have a confusion,,,,can I declare a vector of class instances as a data member in the class itself...and can I use that vector in that class...
like..
class printer{
string Printername;
unsigned int PrinterPort;
.................
...............
vector<printer*> m_vectPrinter;
please help me
Rashmi
|
|
|
|
|
Hi,
yes you can do such things, in C# you would do something like:
static ArrayList allPrinters1;
static List<printer> allPrinters2;
and there must be an equivalent in C++.
You may add initialization code:
static ArrayList allPrinters1=new ArrayList();
static List<printer> allPrinters2=new List<printer>();
You could add code to the constructor so it automatically adds the newly created
printer ("this") to the collection.
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
|
|
|
|
|
Is there a way to copy the events associated with a control to another control?
Like this ( will give a compiler error )
this->button->click = this->otherbutton->click;
Thanks
PS this relates to my earlier post
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
If button and otherbutton is set up this way:
this->button->Click += gcnew System::EventHandler(this, &Form1::button_Click);
this->otherbutton->Click += gcnew System::EventHandler(this, &Form1::otherbutton_Click);
then you can add "otherbutton" to also handle button's event thus:
this->button->Click += gcnew System::EventHandler(this, &Form1::otherbutton_Click);
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I have a list of control names (in String form). Not the WinForm control object but the name of the control object. I need to call the click event associated with that control. I need to do this at run time dynamically.
Is there a way to call that event?
Not this is for a Window Form running in a C++ environment.
Hope you can point me in the right direction.
Thanks
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
|
I have a Listview window with 10 columns. Data are display in the column going left to right with the newest data at the right most column. A horizontal scrollbar is automatically displayed at the bottom and the thumb of the scrollbar is at the left side. I want to put the thumb of the scrollbar to the right side so the when you go to that window you see the newest data first. I tried using GetScrollInfo() but I keep on getting "The window does not have scroll bars." from GetLastError(). I tried using SetScrollInfo() and passing in different values for nPos of the SCROLLINFO structure to see if it would move the thumb, but it doesn't seem to work. Does anyone know how you I get the thumb of the scrollbar to be at the right side?
|
|
|
|
|
|
Hi Mark, thanks for the help, ListView_Scroll() solved the problem I asked. Now I have another problem, when I press the left or right arrow on the scrollbar, I don't receive any WM_HSCROLL messages. I need to check when the thumb is at the far right and the right arrow is press I need to check for newer data and when the thumb is at the far left and the left arrow is press to retrieve older data. Any suggestion why I am not receiving any WM_HSCROLL messages?
|
|
|
|
|
Same situation - we don't know how the common controls are implemented internally
so we can't assume these window messages are available in the standard way.
Just like you should be using ListView messages to control the control ( ), you should
be looking for ListView notifications (LVN_xxxx) instead of standard window messages.
See LVN_BEGINSCROLL/LVN_ENDSCROLL
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
FYI...
I recommend keeping a link to this:
Control Library[^]
or the equivalent link in your local development MSDN library.
It's the documentation for all the Windows common controls, including messages,
notifications, and APIs.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi, I am using Visual Studio 2005 C++/CLI. I have been trying to populate a cell in a grid control but I haven't been able to find any examples that are not C#. I thought I needed to do something like...
DataGridViewCell myCell = gcnew DataGridViewCell(rowValue, colValue);
dataGridview1->CurrentCell = myCell;
dataGridView1->CurrentCell->Value = "Test";
The compiler complains that an abstact class cannot be instantiated. If anyone knows of a link to a CLI example that would be great. I just can't quit seem to figure out how to populate the cells of the DataGridView control (the microsoft .NET documentation hasn't helped).
Thanks
Buck
|
|
|
|
|
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.
|
|
|
|