TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
abdelwaheb ammar
987
457
124.7k
Displaying in DataGridView
Oct 17 2016 8:17 AM
hi, my question is about the datagridview. I create a class ctsContacts with this source code:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
TestingListe
{
class
ctsContacts:lstContacts
{
private
int
_numero;
public
int
Numero
{
get
{
return
_numero; }
set
{ _numero = value; }
}
private
string
_nom;
public
string
Nom
{
get
{
return
_nom; }
set
{ _nom = value; }
}
private
string
_prenom;
public
string
Prenom
{
get
{
return
_prenom; }
set
{ _prenom = value; }
}
private
string
_message;
public
string
Message
{
get
{
return
_message; }
set
{ _message = value; }
}
public
ctsContacts()
{
}
public
ctsContacts(
int
numero,
string
nom,
string
prenom,
string
message)
{
this
.Numero = numero;
this
.Nom = nom;
this
.Prenom = prenom;
this
.Message = message;
}
public
bool
recherche(
int
num)
{
foreach
(ctsContacts search
in
ct)
{
if
(search.Numero == num)
{
return
false
;
}
}
return
true
;
}
public
bool
Ajouter(ctsContacts ctn)
{
if
(
this
.recherche(ctn.Numero) ==
true
)
{
ct.Add(ctn);
return
true
;
}
return
false
;
}
}
}
This class inherits another abstract class that contains a list
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
TestingListe
{
class
lstContacts
{
public
static
List<ctsContacts> ct =
new
List<ctsContacts>();
public
lstContacts()
{
}
}
}
and then in the contact form and add button at this writing source code
private
void
btnajouter_Click(
object
sender, EventArgs e)
{
ctsContacts contact =
new
ctsContacts();
contact.Numero =
int
.Parse(txtnumero.Text);
contact.Nom = txtNom.Text;
contact.Prenom = txtPrenom.Text;
contact.Message = txtmesssage.Text;
contact.Ajouter(contact);
dgvcontacts.DataSource =
null
;
dgvcontacts.DataSource = ctsContacts.ct;
}
the problem is at the datagridview display that copy header right.
and bellow i upload all the project in a .rar file
Attachment:
TestingListe.rar
Reply
Answers (
1
)
How to pass a tableadapter parameter at run time in c#
How to Convert System.Drawings.Bitmap to stdole.IPictureDisp