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
ahmed elbarbary
NA
1.6k
281.4k
How to print selected checkbox in datagridview and in case n
Mar 11 2018 5:01 PM
Actually I need to print records have checkbox checked = true inside datagridview
And if no any record checkbox checked meaning = false checked print all
I need to do that under button print .
No need to go inside code details I need only to implement only pseudo code below :
pseudo code
if
(any records checked checkbox =
true
)
print checked only in datagridview
else
print all in datagridview(in
case
no any checkbox checked inside grid)
my current code print all :
private
void
btnPrint_Click(object sender, EventArgs e)
{
for
(
int
i = 0; i < Grid.Rows.Count; i++)
{
if
(string.IsNullOrEmpty(Convert.ToString(Grid.Rows[i].Cells[
"ItemCode"
].Value)))
return
;
Dictionary<string, string> Formulas =
new
Dictionary<string, string>();
Formulas.Add(
"ImgFlds"
, BarcodePath);
for
(
int
x = 0; x < 4; x++)
{
string formula =
""
;
int
fieldVal = 0;
if
(x == 0)
{
formula =
"lefttopcap"
;
fieldVal = lefttopcap;
}
else
if
(x == 1)
{
formula =
"righttopcap"
;
fieldVal = righttopcap;
}
else
if
(x == 2)
{
formula =
"leftbottomcap"
;
fieldVal = leftbottomcap;
}
else
if
(x == 3)
{
formula =
"rightbottomcap"
;
fieldVal = rightbottomcap;
}
switch
(fieldVal)
{
case
1:
break
;
case
2:
Formulas.Add(formula, Convert.ToString(Grid.Rows[i].Cells[
"CompanyName"
].Value));
break
;
case
3:
Formulas.Add(formula, Convert.ToString(Grid.Rows[i].Cells[
"BranchName"
].Value));
break
;
case
4:
Formulas.Add(formula, Convert.ToString(Grid.Rows[i].Cells[
"ItemLatName"
].Value));
break
;
case
5:
Formulas.Add(formula, Convert.ToString(Grid.Rows[i].Cells[
"ItemAraName"
].Value));
break
;
case
6:
Formulas.Add(formula, Convert.ToString(Grid.Rows[i].Cells[
"SelPrice1"
].Value));
break
;
default
:
break
;
}
}
string sql =
"select * from Branches where 1=1 "
;
int
z = !string.IsNullOrEmpty(Convert.ToString(Grid.Rows[i].Cells[
"ItemCount"
].Value)) ? Convert.ToInt32(Convert.ToString(Grid.Rows[i].Cells[
"ItemCount"
].Value)) : 1;
Reporting.PrinterName = cmbPrinterType.Text;
Reporting.PrintType = PrintTypes.Print;
CreateBarcode(Convert.ToString(Grid.Rows[i].Cells[
"code"
].Value).Trim());
picItem.Image.Save(BarcodePath);
Reporting.ShowReport(
"BarcodePrinting.rpt"
, sql, Formulas, z);
}
}
to get checked checkbox in data gridview as following
bool
isSelected = Convert.ToBoolean(Grid.Rows[i].Cells[
"SelectedPrint"
].Value);
if
(isSelected) { }
Reply
Answers (
1
)
Why dont work update ///another way
Passing parameters for multiple constructors usng single obj