DataGridViewTextBoxCell and binding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello there,

I wrote my own DataDridViewTextBoxCellEx, inherited from
DataGridViewTextBoxCell which accepts an integer (index) as value and
displays the correspondign string out of a dictionary collection.

Now I want to use data binding to connect this collection (a private member
and public property of my DataGridViewTextBoxCellEx) to a database.

Principly I want to do exactly, what the DataGridViewComboBoxCell does, so I
could use that and overwrite the paint event, but I planed to extend my
TextBox with an icon which then must be binded too.

Hoping for help,
Robert
 
Hi Ron,

Thank you for posting.

You could display the page number and number of pages in the header or
footer of a report. To display a page number in the header or footer of a
report, create a text box in the footer and add the following expression:

=Globals.PageNumber & " of " & Globals.TotalPages

For more information, you can refer to
http://msdn2.microsoft.com/en-US/library/ms252093.aspx.

Hope this is helpful to you.
If you have any other concerns or need anything else, please don't hesitate
to let me know.



Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Hi Robert,

Thank you for posting. Firstly, I am terribly sorry making a mistake to put
a reply of another issue to you in my previous email.

I have several questions on your issue.
1. Would you please give me a detailed explain on what you want your own
DataGridViewTextBoxCellEx to do?

2. You have mensioned that "Principly I want to do exactly, what the
DataGridViewComboBoxCell does..". Why not inherite your
DataGidViewTextBoxCellExt from DataGridViewComboBoxCell directly?

3. What do you mean by " but I planed to extend my TextBox with an icon
which then must be binded too"?

As the convenience for research is concerned, would you please send me a
sample project? To get my actual email, please remove the "online" from my
displayed email address.

Thanks.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Hi Linda,

thank you for your response.

I will explain an example, what I'm trying to do.
E.g. I have a Table of Customers. Each Customer has a CustomerNumer, a Name
and an Icon. The Icon should be saved as Image in the database.
Now I want the DataGridView to show a Table of Invoices, where the Customer
is saved with his CustomerNumber.

My DataGridViewTextBoxCell will use the CustomerNumber as Value and
shows the customers Icon and Name.

so far it is working.

Not I want to make my control abel to bound a database to the
CustomerNumber, Name and Icon.
(Like the DataGridViewComboBox does with the DataSource, DisplayMember and
ValueMember)

Cause I also want to bind the icon and do not need the dropdown I decided
not to use the DataGridViewComboBox.

The really (and only) Question now is, how to implement the properties
DataSource, DisplayMember, ValueMember and in my case ImageMember in my
controll.

A mail including an example of my control without data binding is on the way
to you.

Thanks,
Robert

__________________________
 
Hi Robert,

Thank you for your reply. I have received your email with your example.

To the question how to implement the properties DataSource, DisplayMember,
ValueMember and ImageMember in your custom DataGridViewPictureTextBox, I
think a prossible solution may be adding a DataSource(DataTable typed),
DisplayMember(string typed), ValueMember(stirng typed) and
ImageMember(sting typed) property in the DataGridViewPictureTextBoxCell
class. You may get and return the corresponding display string for a
specified value from the DataSource in the override GetFormattedValue
method. And you may get a corresponding image for a specified value from
the DataSource in the override Paint method.

I will go on reseach on this issue to see whether there is a better way to
do it.

I appreciate your patience.

Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Hi Robert,

It seems that there maybe no better way to implement the properties
DataSource, DisplayMember, ValueMember and ImageMember in your custom
DataGridViewPictureTextbox.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
Back
Top