如果GridView Rows Arnt Selected(MessageBox.Show) - 帮助 [英] If GridView Rows Arnt Selected (MessageBox.Show) - HELP

查看:74
本文介绍了如果GridView Rows Arnt Selected(MessageBox.Show) - 帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





这是一个简单的问题,我使用if选项来确定是否在网格视图中未选择行然后显示消息用户选择一个gridview行。



我有以下psuedo代码,但需要帮助将其翻译成C#



如果(GridView1.SelectedRow == 0)

{

MessageBox.Show(先选择一行)

}



请帮我把它转换成C#,PS已经在网上获得了这方面的帮助,但却找不到任何有用的东西。

Hi,

This is a simple question, i am using a if selection to determine if a row isnt selected in a grid view then to show a message telling the user to select a gridview row.

I have the follow psuedo code for it but need help translating it into C#

If(GridView1.SelectedRow == 0)
{
MessageBox.Show(Select A Row First)
}

Please help me converting this to C#, P.S Already lloked online for help for this and couldnt find anything that worked.

推荐答案

你刚刚错过了计数,它计算了所选行的数量。



我用SelectedRows替换了SelectedRow并添加了.count将返回所选行数。



希望这会有所帮助。



You were just missing the count, which counts the amount of selected rows.

I've replaced SelectedRow with SelectedRows and added the .count which will return the number of selected rows.

Hope this helps.

If(GridView1.SelectedRows.Count == 0)
 {
 MessageBox.Show(Select A Row First)
 }


Int32 selectedrowcount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);





if(selectedrowcount> 0)

{

行选择!

}



else



{

plz选择行!

}





用这个给我保佑哈哈哈!
Int32 selectedrowcount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);


if (selectedrowcount > 0)
{
row selected!
}

else

{
plz Select the row!
}


use this and give me bless ha ha ha!


这篇关于如果GridView Rows Arnt Selected(MessageBox.Show) - 帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆