English 中文(简体)
我怎么能把数据网栏作为超链接,从窗口移动应用数据库中提取?
原标题:How can I make datagrid column as HyperLink which is from database in windows mobile application?

In windows mobile application I have DataGrid control which displays data from Database on page_load. I want DataGrid column act as HyperLink so that MessageBox or another window Form will open and show the detail contents of selected DatGrid column .

问题回答

You can just capture the click event and use the contents of the column to open your web address

如果您的表格各有三栏,每栏有一栏。

    DataTable dataTable = new DataTable();
    dataTable.Columns.Add("Website1", typeof(String));
    dataTable.Columns.Add("Website2", typeof(String));
    dataTable.Columns.Add("Website3", typeof(String));

    DataRow dr = dataTable.NewRow();
    dr["Website1"] = "http://www.bbc.co.uk";
    dr["Website2"] = "http://www.ebay.co.uk";
    dr["Website3"] = "http://www.google.co.uk";
    dataTable.Rows.Add(dr);

    dataGrid1.DataSource = dataTable;

然后,你可以把这作为超级链接。

    private void dataGrid1_Click(object sender, EventArgs e)
    {
        int rowNumber = dataGrid1.CurrentCell.RowNumber;
        int columnNumber = dataGrid1.CurrentCell.ColumnNumber;

        System.Diagnostics.Process.Start("iexplore.exe", 
                       dgSites[rowNumber, columnNumber].ToString());
    }

如果你只想用一个栏子来启动你的联系,那么仅仅通过核对栏号来考虑这一点。

    private void dataGrid1_Click(object sender, EventArgs e)
    {
        int rowNumber = dataGrid1.CurrentCell.RowNumber;
        int columnNumber = dataGrid1.CurrentCell.ColumnNumber;

        if (columnNumber == 2)
        {
          System.Diagnostics.Process.Start("iexplore.exe", 
                       dgSites[rowNumber, columnNumber].ToString());
        }
    }

问题完全是要你努力做到,但是,如果你只是想在信息箱中显示该项目,那就不清楚。

    private void dataGrid1_Click(object sender, EventArgs e)
    {
        int rowNumber = dataGrid1.CurrentCell.RowNumber;
        int columnNumber = dataGrid1.CurrentCell.ColumnNumber;

        if (columnNumber == 2)
        {
          MessageBox.Show(dgSites[rowNumber, columnNumber].ToString());
        }
    }




相关问题
Using maps on Windows Mobile

I m experimenting with maps on different mobile platforms. Getting Google Maps to work on Android was easy, following this tutorial. Getting the same to work on Windows Mobile is a different matter. ...

Build a Bitmap filling it with a smaller image

I m developing a Windows Mobile application with C# and .NET Compact Framework. I want to fill a Bitmap with an image that it s smaller. To fill this new Bitmap I want to repeat the image ...

Bing maps used offline: cache tiles from its web service

I m developing a Windows Mobile application that uses Bing Maps Web Service to show user s position on it. I think I have a problem if the user hasn t got internet service on his mobile, so I think I ...

Determine Mobile Internet Explorer version

I need to determine the version of Mobile Internet Explorer on a Windows Mobile 6.1 device. So that I can report the same user-agent string as is being used by Mobile Internet Explorer. The user-...

Custom listview control for windows mobile in c#

I need to develop a custom listview control (ie, i need two labels and a progress bar in each list item) . I am new to windows mobile so please help me with code samples.

In Which Languages Can I Develop For Windows Mobile?

Today my new HP iPAQ was delivered at my home, but now I want to know two things before I start any project: In which languages can I develop for it(Windows Mobile 5)? Where can I download this ...

热门标签