abyssal whale
abyssal whale

Reputation: 75

How to display 1 button per 1 line in telegram bot?

I'm adding keyboard to my bot by using InlineKeyboardMarkup. In code below: all buttons are shown in 1 line. How can I achieve that 1 button will be shown per a 1 line?

Thanks for your time.

var mainKeyBoard = new InlineKeyboardMarkup(new[] 
{
InlineKeyboardButton.WithCallbackData("beer"), InlineKeyboardButton.WithCallbackData("price"), 
InlineKeyboardButton.WithCallbackData("support") 
});

Upvotes: 0

Views: 2174

Answers (1)

abyssal whale
abyssal whale

Reputation: 75

Figured it out. New row requires new array into array. For my sample above it work like this:

 static InlineKeyboardMarkup mainKeyBoard = new InlineKeyboardMarkup(new[] {
            new[]
            {
                InlineKeyboardButton.WithCallbackData("beer")
            },
            new[]
            {
                InlineKeyboardButton.WithCallbackData("price"),
            },
            new[]
            {
                InlineKeyboardButton.WithCallbackData("support")
            }
        });

Upvotes: 3

Related Questions